diff options
Diffstat (limited to 'native/jni/src/additional_proximity_chars.h')
-rw-r--r-- | native/jni/src/additional_proximity_chars.h | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/native/jni/src/additional_proximity_chars.h b/native/jni/src/additional_proximity_chars.h index ba76cfced..1fe996d0d 100644 --- a/native/jni/src/additional_proximity_chars.h +++ b/native/jni/src/additional_proximity_chars.h @@ -17,8 +17,8 @@ #ifndef LATINIME_ADDITIONAL_PROXIMITY_CHARS_H #define LATINIME_ADDITIONAL_PROXIMITY_CHARS_H +#include <cstring> #include <stdint.h> -#include <string> #include "defines.h" @@ -27,7 +27,7 @@ namespace latinime { class AdditionalProximityChars { private: DISALLOW_IMPLICIT_CONSTRUCTORS(AdditionalProximityChars); - static const std::string LOCALE_EN_US; + static const char *LOCALE_EN_US; static const int EN_US_ADDITIONAL_A_SIZE = 4; static const int32_t EN_US_ADDITIONAL_A[]; static const int EN_US_ADDITIONAL_E_SIZE = 4; @@ -39,14 +39,15 @@ class AdditionalProximityChars { static const int EN_US_ADDITIONAL_U_SIZE = 4; static const int32_t EN_US_ADDITIONAL_U[]; - static bool isEnLocale(const std::string *locale_str) { - return locale_str && locale_str->size() >= LOCALE_EN_US.size() - && LOCALE_EN_US.compare(0, LOCALE_EN_US.size(), *locale_str); + static bool isEnLocale(const char *localeStr) { + const size_t LOCALE_EN_US_SIZE = strlen(LOCALE_EN_US); + return localeStr && strlen(localeStr) >= LOCALE_EN_US_SIZE + && strncmp(localeStr, LOCALE_EN_US, LOCALE_EN_US_SIZE) == 0; } public: - static int getAdditionalCharsSize(const std::string *locale_str, const int32_t c) { - if (!isEnLocale(locale_str)) { + static int getAdditionalCharsSize(const char *localeStr, const int32_t c) { + if (!isEnLocale(localeStr)) { return 0; } switch(c) { @@ -65,8 +66,8 @@ class AdditionalProximityChars { } } - static const int32_t *getAdditionalChars(const std::string *locale_str, const int32_t c) { - if (!isEnLocale(locale_str)) { + static const int32_t *getAdditionalChars(const char *localeStr, const int32_t c) { + if (!isEnLocale(localeStr)) { return 0; } switch(c) { @@ -84,10 +85,6 @@ class AdditionalProximityChars { return 0; } } - - static bool hasAdditionalChars(const std::string *locale_str, const int32_t c) { - return getAdditionalCharsSize(locale_str, c) > 0; - } }; } // namespace latinime #endif // LATINIME_ADDITIONAL_PROXIMITY_CHARS_H |