Recycle TemporaryBuffer for reducing object count

Bug: 216219602
Test: N/A
Change-Id: I1d0ca1719b2ec807249a47201fe62ccd06cf74e5
This commit is contained in:
Seigo Nonaka
2022-01-25 15:27:50 +09:00
parent ea85bfc929
commit 777d2c26b6

View File

@@ -2184,9 +2184,13 @@ public class Paint {
contextCount, isRtl, outMetrics);
} else {
char[] buf = TemporaryBuffer.obtain(contextCount);
TextUtils.getChars(text, contextStart, contextStart + contextCount, buf, 0);
nGetFontMetricsIntForText(mNativePaint, buf, start - contextStart, count, 0,
contextCount, isRtl, outMetrics);
try {
TextUtils.getChars(text, contextStart, contextStart + contextCount, buf, 0);
nGetFontMetricsIntForText(mNativePaint, buf, start - contextStart, count, 0,
contextCount, isRtl, outMetrics);
} finally {
TemporaryBuffer.recycle(buf);
}
}
}