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

Commit 63c885f8 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Bug 5250788: Fix memory consumption issues in TextPaint.

The increased size array was discarded in set. Reuse it instead if
possible to avoid more size increases later.

Change-Id: I9ab95ed0f4d4613dd1e28f02894bb19ecee7df41
parent 166c1b2e
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -72,8 +72,15 @@ public class TextPaint extends Paint {
        linkColor = tp.linkColor;
        drawableState = tp.drawableState;
        density = tp.density;
        underlineColors = tp.underlineColors;
        underlineThicknesses = tp.underlineThicknesses;

        if (tp.underlineColors != null) {
            if (underlineColors == null || underlineColors.length < tp.underlineCount) {
                underlineColors = new int[tp.underlineCount];
                underlineThicknesses = new float[tp.underlineCount];
            }
            System.arraycopy(tp.underlineColors, 0, underlineColors, 0, tp.underlineCount);
            System.arraycopy(tp.underlineThicknesses, 0, underlineThicknesses, 0, tp.underlineCount);
        }
        underlineCount = tp.underlineCount;
    }