summaryrefslogtreecommitdiffstats
path: root/core/jni/android/graphics/TextLayoutCache.cpp
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2011-10-03 09:56:32 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-03 09:56:32 -0700
commiteb3b750c1df8429f88ba28dc3bf02b28dee9ca40 (patch)
tree432412e1ac90348b850ebf6c8e15dfebc0a69f1b /core/jni/android/graphics/TextLayoutCache.cpp
parent7b1c30dfda65adfaf15fc03daf800b8d99a86f79 (diff)
parent717060b076350ea811153290281075396a554fed (diff)
downloadframeworks_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.cpp46
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() {