From 1d442e0d990b581357f33f5463c7c5cb49b551e8 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 20 Apr 2009 18:14:05 -0700 Subject: More optimization of dumpsys output. There are three major classes of changes here: - Avoid writing lines where their values are often empty, false, or some other typical thing. - Use partial writes to the PrintWriter to avoid creating temporary strings. - Use StringBuilder where we need to generate real String objects (and where possible cache the result). --- .../android/view/animation/Transformation.java | 32 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'core/java/android/view') diff --git a/core/java/android/view/animation/Transformation.java b/core/java/android/view/animation/Transformation.java index f9e85bf..cf210c8 100644 --- a/core/java/android/view/animation/Transformation.java +++ b/core/java/android/view/animation/Transformation.java @@ -18,6 +18,8 @@ package android.view.animation; import android.graphics.Matrix; +import java.io.PrintWriter; + /** * Defines the transformation to be applied at * one point in time of an Animation. @@ -134,14 +136,38 @@ public class Transformation { @Override public String toString() { - return "Transformation{alpha=" + mAlpha + " matrix=" - + mMatrix.toShortString() + "}"; + StringBuilder sb = new StringBuilder(64); + sb.append("Transformation"); + toShortString(sb); + return sb.toString(); } /** * Return a string representation of the transformation in a compact form. */ public String toShortString() { - return "{alpha=" + mAlpha + " matrix=" + mMatrix.toShortString() + "}"; + StringBuilder sb = new StringBuilder(64); + toShortString(sb); + return sb.toString(); + } + + /** + * @hide + */ + public void toShortString(StringBuilder sb) { + sb.append("{alpha="); sb.append(mAlpha); + sb.append(" matrix="); mMatrix.toShortString(sb); + sb.append('}'); + } + + /** + * Print short string, to optimize dumping. + * @hide + */ + public void printShortString(PrintWriter pw) { + pw.print("{alpha="); pw.print(mAlpha); + pw.print(" matrix="); + mMatrix.printShortString(pw); + pw.print('}'); } } -- cgit v1.1