OSDN Git Service

TextLine cache is used, even for long lines of text.
authorGilles Debunne <debunne@google.com>
Tue, 25 Jan 2011 17:09:46 +0000 (09:09 -0800)
committerGilles Debunne <debunne@google.com>
Tue, 25 Jan 2011 17:09:46 +0000 (09:09 -0800)
Bug 3381368

The 250 characters limit is passed for long URLs. There are only 3
TextLine objects, so their total size is not an issue. Recycle long
lines as well to make sure we fill the cache and avoid object creation.

Change-Id: I843bf623594312a0fcf0edbb13b7cd64cce0ddd1

core/java/android/text/TextLine.java

index a6fd2f1..90279d1 100644 (file)
@@ -90,13 +90,11 @@ class TextLine {
         tl.mText = null;
         tl.mPaint = null;
         tl.mDirections = null;
-        if (tl.mLen < 250) {
-            synchronized(cached) {
-                for (int i = 0; i < cached.length; ++i) {
-                    if (cached[i] == null) {
-                        cached[i] = tl;
-                        break;
-                    }
+        synchronized(cached) {
+            for (int i = 0; i < cached.length; ++i) {
+                if (cached[i] == null) {
+                    cached[i] = tl;
+                    break;
                 }
             }
         }