Skip to content

Commit 63c885f

Browse files
author
Gilles Debunne
committed
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
1 parent 166c1b2 commit 63c885f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

core/java/android/text/TextPaint.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,15 @@ public void set(TextPaint tp) {
7272
linkColor = tp.linkColor;
7373
drawableState = tp.drawableState;
7474
density = tp.density;
75-
underlineColors = tp.underlineColors;
76-
underlineThicknesses = tp.underlineThicknesses;
75+
76+
if (tp.underlineColors != null) {
77+
if (underlineColors == null || underlineColors.length < tp.underlineCount) {
78+
underlineColors = new int[tp.underlineCount];
79+
underlineThicknesses = new float[tp.underlineCount];
80+
}
81+
System.arraycopy(tp.underlineColors, 0, underlineColors, 0, tp.underlineCount);
82+
System.arraycopy(tp.underlineThicknesses, 0, underlineThicknesses, 0, tp.underlineCount);
83+
}
7784
underlineCount = tp.underlineCount;
7885
}
7986

0 commit comments

Comments
 (0)