Increase initial StringBuffer capacity in View.toString.

128 was probably a reasonable number back when class names were shorter,
and we only had one flags field, and there were no kids on my lawn.
But modern views often exceed 128 bytes when stringified, resulting in
another allocation and array copy.

256 ought to be enough for anybody.

Change-Id: Ib7d4bc4948eb36f42b0e0d35f672398b3bbcea33
Test: atest, presubmit
Fixes: 189276070
This commit is contained in:
Daniel Sandler
2021-05-26 04:49:51 +00:00
parent d0208e168b
commit db28ed585f

View File

@@ -6431,7 +6431,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
@Override
public String toString() {
StringBuilder out = new StringBuilder(128);
StringBuilder out = new StringBuilder(256);
out.append(getClass().getName());
out.append('{');
out.append(Integer.toHexString(System.identityHashCode(this)));