am 6dc003a7: Merge "Reduce footprint of Signature from ~7000 to ~1448" into gingerbread

Merge commit '6dc003a73f7f01aa5dd5831e777e2aa44f65b032' into gingerbread-plus-aosp

* commit '6dc003a73f7f01aa5dd5831e777e2aa44f65b032':
  Reduce footprint of Signature from ~7000 to ~1448
This commit is contained in:
Kenny Root
2010-09-03 17:07:15 -07:00
committed by Android Git Automerger

View File

@@ -20,6 +20,7 @@ import android.content.ComponentName;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import java.lang.ref.SoftReference;
import java.util.Arrays; import java.util.Arrays;
/** /**
@@ -30,7 +31,7 @@ public class Signature implements Parcelable {
private final byte[] mSignature; private final byte[] mSignature;
private int mHashCode; private int mHashCode;
private boolean mHaveHashCode; private boolean mHaveHashCode;
private String mString; private SoftReference<String> mStringRef;
/** /**
* Create Signature from an existing raw byte array. * Create Signature from an existing raw byte array.
@@ -96,10 +97,13 @@ public class Signature implements Parcelable {
* cached so future calls will return the same String. * cached so future calls will return the same String.
*/ */
public String toCharsString() { public String toCharsString() {
if (mString != null) return mString; String str = mStringRef == null ? null : mStringRef.get();
String str = new String(toChars()); if (str != null) {
mString = str; return str;
return mString; }
str = new String(toChars());
mStringRef = new SoftReference<String>(str);
return str;
} }
/** /**