diff options
| author | James Cook <jamescook@google.com> | 2015-02-23 16:17:28 -0800 |
|---|---|---|
| committer | James Cook <jamescook@google.com> | 2015-02-23 16:20:16 -0800 |
| commit | 761a4b333548bea72fe9df64cb70dc9c3400126f (patch) | |
| tree | 0ab7c127690f7ecf446a345913b2e2635ca58dea /core/java | |
| parent | 6a8253fdc9f4574c28b4beeeed90580ffc93734a (diff) | |
| download | frameworks_base-761a4b333548bea72fe9df64cb70dc9c3400126f.zip frameworks_base-761a4b333548bea72fe9df64cb70dc9c3400126f.tar.gz frameworks_base-761a4b333548bea72fe9df64cb70dc9c3400126f.tar.bz2 | |
Change UndoManager mOwners from HashMap to ArrayMap
The number of undo operation owners is small (and usually one),
so save memory by switching to ArrayMap.
Bug: 19332904
Change-Id: Ic32cd49c292db2eaab1739cea8e8e518e68bd826
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/content/UndoManager.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/java/android/content/UndoManager.java b/core/java/android/content/UndoManager.java index e9ec5a4..e3bc238 100644 --- a/core/java/android/content/UndoManager.java +++ b/core/java/android/content/UndoManager.java @@ -20,9 +20,9 @@ import android.os.Parcel; import android.os.Parcelable; import android.os.ParcelableParcel; import android.text.TextUtils; +import android.util.ArrayMap; import java.util.ArrayList; -import java.util.HashMap; /** * Top-level class for managing and interacting with the global undo state for @@ -54,7 +54,9 @@ import java.util.HashMap; * @hide */ public class UndoManager { - private final HashMap<String, UndoOwner> mOwners = new HashMap<String, UndoOwner>(); + // The common case is a single undo owner (e.g. for a TextView), so default to that capacity. + private final ArrayMap<String, UndoOwner> mOwners = + new ArrayMap<String, UndoOwner>(1 /* capacity */); private final ArrayList<UndoState> mUndos = new ArrayList<UndoState>(); private final ArrayList<UndoState> mRedos = new ArrayList<UndoState>(); private int mUpdateCount; |
