Merge pull request #7421 from taosdata/enhance/TD-6165-2.0
[TD-6165]<enhance>: use memcpy to replace wcsncmp for nchar type comparision
This commit is contained in:
commit
79c2eca8dc
|
@ -129,16 +129,7 @@ int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) {
|
|||
if (len1 != len2) {
|
||||
return len1 > len2? 1:-1;
|
||||
} else {
|
||||
char *pLeftTerm = (char *)tcalloc(len1 + 1, sizeof(char));
|
||||
char *pRightTerm = (char *)tcalloc(len1 + 1, sizeof(char));
|
||||
memcpy(pLeftTerm, varDataVal(pLeft), len1);
|
||||
memcpy(pRightTerm, varDataVal(pRight), len2);
|
||||
|
||||
int32_t ret = wcsncmp((wchar_t*) pLeftTerm, (wchar_t*) pRightTerm, len1/TSDB_NCHAR_SIZE);
|
||||
|
||||
tfree(pLeftTerm);
|
||||
tfree(pRightTerm);
|
||||
|
||||
int32_t ret = memcmp((wchar_t*) pLeft, (wchar_t*) pRight, len1);
|
||||
if (ret == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -418,17 +409,7 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
|
|||
if (t1->len != t2->len) {
|
||||
return t1->len > t2->len? 1:-1;
|
||||
}
|
||||
|
||||
char *t1_term = (char *)tcalloc(t1->len + 1, sizeof(char));
|
||||
char *t2_term = (char *)tcalloc(t2->len + 1, sizeof(char));
|
||||
memcpy(t1_term, t1->data, t1->len);
|
||||
memcpy(t2_term, t2->data, t2->len);
|
||||
|
||||
int32_t ret = wcsncmp((wchar_t*) t1_term, (wchar_t*) t2_term, t2->len/TSDB_NCHAR_SIZE);
|
||||
|
||||
tfree(t1_term);
|
||||
tfree(t2_term);
|
||||
|
||||
int32_t ret = memcmp((wchar_t*) t1, (wchar_t*) t2, t2->len);
|
||||
if (ret == 0) {
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue