diff options
| author | John Reck <jreck@google.com> | 2015-07-10 18:00:50 +0000 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2015-07-10 18:00:50 +0000 |
| commit | b25c0bb7ad06c7339555b54e17e183e04ed40d13 (patch) | |
| tree | 6c7bd505c3d490cc82d08609c0f534a7bddd066a | |
| parent | d38de2a14d59d99eba9e2611132ff50a0e825ae2 (diff) | |
| parent | 525ac80d2dda4ce7a902b67d082ed26d0986f525 (diff) | |
| download | frameworks_base-b25c0bb7ad06c7339555b54e17e183e04ed40d13.zip frameworks_base-b25c0bb7ad06c7339555b54e17e183e04ed40d13.tar.gz frameworks_base-b25c0bb7ad06c7339555b54e17e183e04ed40d13.tar.bz2 | |
am 525ac80d: Merge "Create a thread_local cache for textLocale" into mnc-dev
* commit '525ac80d2dda4ce7a902b67d082ed26d0986f525':
Create a thread_local cache for textLocale
| -rw-r--r-- | core/jni/android/graphics/Paint.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp index b9fd65f..bff1885 100644 --- a/core/jni/android/graphics/Paint.cpp +++ b/core/jni/android/graphics/Paint.cpp @@ -74,6 +74,13 @@ static void defaultSettingsForAndroid(Paint* paint) { paint->setTextEncoding(Paint::kGlyphID_TextEncoding); } +struct LocaleCacheEntry { + std::string javaLocale; + std::string languageTag; +}; + +static thread_local LocaleCacheEntry sSingleEntryLocaleCache; + class PaintGlue { public: enum MoveOpt { @@ -399,10 +406,14 @@ public: static void setTextLocale(JNIEnv* env, jobject clazz, jlong objHandle, jstring locale) { Paint* obj = reinterpret_cast<Paint*>(objHandle); ScopedUtfChars localeChars(env, locale); - char langTag[ULOC_FULLNAME_CAPACITY]; - toLanguageTag(langTag, ULOC_FULLNAME_CAPACITY, localeChars.c_str()); + if (sSingleEntryLocaleCache.javaLocale != localeChars.c_str()) { + sSingleEntryLocaleCache.javaLocale = localeChars.c_str(); + char langTag[ULOC_FULLNAME_CAPACITY]; + toLanguageTag(langTag, ULOC_FULLNAME_CAPACITY, localeChars.c_str()); + sSingleEntryLocaleCache.languageTag = langTag; + } - obj->setTextLocale(langTag); + obj->setTextLocale(sSingleEntryLocaleCache.languageTag); } static jboolean isElegantTextHeight(JNIEnv* env, jobject paint) { |
