diff options
author | Chris Craik <ccraik@google.com> | 2015-07-10 13:12:34 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2015-07-10 13:12:35 -0700 |
commit | fc121c2430cd27c0d9b655105a9ab1c261c10bdc (patch) | |
tree | 9bf9ca3e02cc8a6a4614743de27d9282134a8974 /core/java/android/text | |
parent | 5d21f4168e7e8625427eb2210e59b30bff5b3b85 (diff) | |
download | frameworks_base-fc121c2430cd27c0d9b655105a9ab1c261c10bdc.zip frameworks_base-fc121c2430cd27c0d9b655105a9ab1c261c10bdc.tar.gz frameworks_base-fc121c2430cd27c0d9b655105a9ab1c261c10bdc.tar.bz2 |
Reduce cost of span type checking
bug:22378829
Change-Id: I1da5154b2fb4f5032eaed44586d5470d28ceb45b
Diffstat (limited to 'core/java/android/text')
-rw-r--r-- | core/java/android/text/SpannableStringInternal.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/java/android/text/SpannableStringInternal.java b/core/java/android/text/SpannableStringInternal.java index d114d32..5c5deb4 100644 --- a/core/java/android/text/SpannableStringInternal.java +++ b/core/java/android/text/SpannableStringInternal.java @@ -214,10 +214,6 @@ import java.lang.reflect.Array; Object ret1 = null; for (int i = 0; i < spanCount; i++) { - if (kind != null && !kind.isInstance(spans[i])) { - continue; - } - int spanStart = data[i * COLUMNS + START]; int spanEnd = data[i * COLUMNS + END]; @@ -237,6 +233,11 @@ import java.lang.reflect.Array; } } + // verify span class as late as possible, since it is expensive + if (kind != null && !kind.isInstance(spans[i])) { + continue; + } + if (count == 0) { ret1 = spans[i]; count++; |