提交 d2dcecda 编写于 作者: G Ganlin Zhao

[TD-5619]<fix>: optimized checkTzPresent function

上级 3cfb2ea9
...@@ -110,10 +110,15 @@ bool checkTzPresent(char *str, int32_t len) { ...@@ -110,10 +110,15 @@ bool checkTzPresent(char *str, int32_t len) {
char *seg = forwardToTimeStringEnd(str); char *seg = forwardToTimeStringEnd(str);
int32_t seg_len = len - (int32_t)(seg - str); int32_t seg_len = len - (int32_t)(seg - str);
return (strnchr(seg, 'Z', seg_len, false) != NULL || char *c = &seg[seg_len - 1];
strnchr(seg, 'z', seg_len, false) != NULL || for (int i = 0; i < seg_len; ++i) {
strnchr(seg, '+', seg_len, false) != NULL || if (*c == 'Z' || *c == 'z' || *c == '+' || *c == '-') {
strnchr(seg, '-', seg_len, false) != NULL); return true;
}
c--;
}
return false;
} }
char* forwardToTimeStringEnd(char* str) { char* forwardToTimeStringEnd(char* str) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册