aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2016-02-08 00:06:24 -0800
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2016-02-08 00:06:24 -0800
commitaa80a00642039403ad21462541765d520645471f (patch)
tree502c77a92a716f989153ead31b6b52156cea009d
parent73510821024cc8e79b22238609810e6a72d320f3 (diff)
Optimization
-rw-r--r--src/core/basetypes/MCString.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/core/basetypes/MCString.cpp b/src/core/basetypes/MCString.cpp
index 9c024067..6a10b13c 100644
--- a/src/core/basetypes/MCString.cpp
+++ b/src/core/basetypes/MCString.cpp
@@ -8,7 +8,9 @@
#include <string.h>
#include <stdlib.h>
-#if !DISABLE_ICU
+#if DISABLE_ICU
+#include <unicode/ustring.h>
+#else
#include <unicode/ustring.h>
#include <unicode/ucnv.h>
#include <unicode/utypes.h>
@@ -55,7 +57,7 @@ static String * s_unicode160 = NULL;
static String * s_unicode133 = NULL;
static String * s_unicode2028 = NULL;
-#if DISABLE_ICU
+#if DISABLE_ICU && 0
static int32_t u_strlen(const UChar *s) {
if (s == NULL) {
return 0;
@@ -1221,12 +1223,17 @@ int String::compareWithCaseSensitive(String * otherString, bool caseSensitive)
}
#if DISABLE_ICU
- CFStringRef cfThis = CFStringCreateWithCharactersNoCopy(NULL, mUnicodeChars, mLength, kCFAllocatorNull);
- CFStringRef cfOther = CFStringCreateWithCharactersNoCopy(NULL, otherString->mUnicodeChars, otherString->mLength, kCFAllocatorNull);
- CFComparisonResult result = CFStringCompare(cfThis, cfOther, caseSensitive ? 0 : kCFCompareCaseInsensitive);
- CFRelease(cfThis);
- CFRelease(cfOther);
- return result;
+ if (caseSensitive) {
+ return u_strcmp(unicodeCharacters(), otherString->unicodeCharacters());
+ }
+ else {
+ CFStringRef cfThis = CFStringCreateWithCharactersNoCopy(NULL, mUnicodeChars, mLength, kCFAllocatorNull);
+ CFStringRef cfOther = CFStringCreateWithCharactersNoCopy(NULL, otherString->mUnicodeChars, otherString->mLength, kCFAllocatorNull);
+ CFComparisonResult result = CFStringCompare(cfThis, cfOther, kCFCompareCaseInsensitive);
+ CFRelease(cfThis);
+ CFRelease(cfOther);
+ return result;
+ }
#else
if (caseSensitive) {
return u_strcmp(unicodeCharacters(), otherString->unicodeCharacters());