From d2dcecda649e8cb11e018c8f5c6c2246d7c9d9f2 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Thu, 5 Aug 2021 16:25:15 +0800 Subject: [PATCH] [TD-5619]: optimized checkTzPresent function --- src/os/src/detail/osTime.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/os/src/detail/osTime.c b/src/os/src/detail/osTime.c index 078b9c62d0..44c6a7d74c 100644 --- a/src/os/src/detail/osTime.c +++ b/src/os/src/detail/osTime.c @@ -110,10 +110,15 @@ bool checkTzPresent(char *str, int32_t len) { char *seg = forwardToTimeStringEnd(str); int32_t seg_len = len - (int32_t)(seg - str); - return (strnchr(seg, 'Z', seg_len, false) != NULL || - strnchr(seg, 'z', seg_len, false) != NULL || - strnchr(seg, '+', seg_len, false) != NULL || - strnchr(seg, '-', seg_len, false) != NULL); + char *c = &seg[seg_len - 1]; + for (int i = 0; i < seg_len; ++i) { + if (*c == 'Z' || *c == 'z' || *c == '+' || *c == '-') { + return true; + } + c--; + } + return false; + } char* forwardToTimeStringEnd(char* str) { -- GitLab