diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2011-10-03 09:56:32 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-10-03 09:56:32 -0700 |
commit | eb3b750c1df8429f88ba28dc3bf02b28dee9ca40 (patch) | |
tree | 432412e1ac90348b850ebf6c8e15dfebc0a69f1b /core/jni/android/graphics/TextLayoutCache.cpp | |
parent | 7b1c30dfda65adfaf15fc03daf800b8d99a86f79 (diff) | |
parent | 717060b076350ea811153290281075396a554fed (diff) | |
download | frameworks_base-eb3b750c1df8429f88ba28dc3bf02b28dee9ca40.zip frameworks_base-eb3b750c1df8429f88ba28dc3bf02b28dee9ca40.tar.gz frameworks_base-eb3b750c1df8429f88ba28dc3bf02b28dee9ca40.tar.bz2 |
Merge "Improve TextLayoutCache performances a bit"
Diffstat (limited to 'core/jni/android/graphics/TextLayoutCache.cpp')
-rw-r--r-- | core/jni/android/graphics/TextLayoutCache.cpp | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index 86ae7d2..3c70c30 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -251,26 +251,32 @@ TextLayoutCacheKey::TextLayoutCacheKey(const TextLayoutCacheKey& other) : } } -bool TextLayoutCacheKey::operator<(const TextLayoutCacheKey& rhs) const { - LTE_INT(count) { - LTE_INT(typeface) { - LTE_FLOAT(textSize) { - LTE_FLOAT(textSkewX) { - LTE_FLOAT(textScaleX) { - LTE_INT(flags) { - LTE_INT(hinting) { - LTE_INT(dirFlags) { - return memcmp(getText(), rhs.getText(), - count * sizeof(UChar)) < 0; - } - } - } - } - } - } - } - } - return false; +int TextLayoutCacheKey::compare(const TextLayoutCacheKey& lhs, const TextLayoutCacheKey& rhs) { + int deltaInt = lhs.count - rhs.count; + if (deltaInt != 0) return (deltaInt); + + if (lhs.typeface < rhs.typeface) return -1; + if (lhs.typeface > rhs.typeface) return +1; + + if (lhs.textSize < rhs.textSize) return -1; + if (lhs.textSize > rhs.textSize) return +1; + + if (lhs.textSkewX < rhs.textSkewX) return -1; + if (lhs.textSkewX > rhs.textSkewX) return +1; + + if (lhs.textScaleX < rhs.textScaleX) return -1; + if (lhs.textScaleX > rhs.textScaleX) return +1; + + deltaInt = lhs.flags - rhs.flags; + if (deltaInt != 0) return (deltaInt); + + deltaInt = lhs.hinting - rhs.hinting; + if (deltaInt != 0) return (deltaInt); + + deltaInt = lhs.dirFlags - rhs.dirFlags; + if (deltaInt) return (deltaInt); + + return memcmp(lhs.getText(), rhs.getText(), lhs.count * sizeof(UChar)); } void TextLayoutCacheKey::internalTextCopy() { |