Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3781f8d6 authored by Seigo Nonaka's avatar Seigo Nonaka Committed by Android Build Coastguard Worker
Browse files

Improve ellipsize performance

Instead of iterate all ellipsized characters, only iterate the necessary
ranges for copying.

Bug: 188913943
Test: atest CtsTextTestCases CtsGraphicsTestCases CtsWidgetTestCases
Change-Id: I3d03b1e3897e427c23fbe51315f412c57a4ce9e9
(cherry picked from commit 2c6121f3)
(cherry picked from commit 599f1b76)
parent 5fae544a
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -2350,7 +2350,10 @@ public abstract class Layout {
        final int ellipsisStringLen = ellipsisString.length();
        // Use the ellipsis string only if there are that at least as many characters to replace.
        final boolean useEllipsisString = ellipsisCount >= ellipsisStringLen;
        for (int i = 0; i < ellipsisCount; i++) {
        final int min = Math.max(0, start - ellipsisStart - lineStart);
        final int max = Math.min(ellipsisCount, end - ellipsisStart - lineStart);

        for (int i = min; i < max; i++) {
            final char c;
            if (useEllipsisString && i < ellipsisStringLen) {
                c = ellipsisString.charAt(i);
@@ -2359,11 +2362,9 @@ public abstract class Layout {
            }

            final int a = i + ellipsisStart + lineStart;
            if (start <= a && a < end) {
            dest[destoff + a - start] = c;
        }
    }
    }

    /**
     * Stores information about bidirectional (left-to-right or right-to-left)