Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4bf0ae2 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

New ArrayMap class.

This is a new kind of key/value mapping that stores its data
as an array, so it doesn't need to create an extra Entry object
for every mapping placed in to it.  It is also optimized to reduce
memory overhead in other ways, by keeping the base object small,
being fairly aggressive about keeping the array data structures
small, etc.

There are some unit and performance tests dropped in to some
random places; they will need to be put somewhere else once I
decided what we are going to do with this for the next release
(for example if we make it public the unit tests should go in
to CTS).

Switch IntentResolver to using ArrayMap instead of HashMap.

Also get rid of a bunch of duplicate implementations of binarySearch,
and add an optimization to the various sparse arrays where you can
supply an explicit 0 capacity to prevent it from doing an initial
array allocation; use this new optimization in a few places where it
makes sense.

Change-Id: I01ef2764680f8ae49938e2a2ed40dc01606a056b
parent b631eda3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -204,13 +204,13 @@ class LoaderManagerImpl extends LoaderManager {
    // These are the currently active loaders.  A loader is here
    // from the time its load is started until it has been explicitly
    // stopped or restarted by the application.
    final SparseArray<LoaderInfo> mLoaders = new SparseArray<LoaderInfo>();
    final SparseArray<LoaderInfo> mLoaders = new SparseArray<LoaderInfo>(0);

    // These are previously run loaders.  This list is maintained internally
    // to avoid destroying a loader while an application is still using it.
    // It allows an application to restart a loader, but continue using its
    // previously run loader until the new loader's data is available.
    final SparseArray<LoaderInfo> mInactiveLoaders = new SparseArray<LoaderInfo>();
    final SparseArray<LoaderInfo> mInactiveLoaders = new SparseArray<LoaderInfo>(0);

    final String mWho;

+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ public abstract class RegisteredServicesCache<V> {
    @GuardedBy("mServicesLock")
    private boolean mPersistentServicesFileDidNotExist;
    @GuardedBy("mServicesLock")
    private final SparseArray<UserServices<V>> mUserServices = new SparseArray<UserServices<V>>();
    private final SparseArray<UserServices<V>> mUserServices = new SparseArray<UserServices<V>>(2);

    private static class UserServices<V> {
        @GuardedBy("mServicesLock")
+3 −3
Original line number Diff line number Diff line
@@ -99,11 +99,11 @@ public class Resources {
    /*package*/ final Configuration mTmpConfig = new Configuration();
    /*package*/ TypedValue mTmpValue = new TypedValue();
    /*package*/ final LongSparseArray<WeakReference<Drawable.ConstantState> > mDrawableCache
            = new LongSparseArray<WeakReference<Drawable.ConstantState> >();
            = new LongSparseArray<WeakReference<Drawable.ConstantState> >(0);
    /*package*/ final LongSparseArray<WeakReference<ColorStateList> > mColorStateListCache
            = new LongSparseArray<WeakReference<ColorStateList> >();
            = new LongSparseArray<WeakReference<ColorStateList> >(0);
    /*package*/ final LongSparseArray<WeakReference<Drawable.ConstantState> > mColorDrawableCache
            = new LongSparseArray<WeakReference<Drawable.ConstantState> >();
            = new LongSparseArray<WeakReference<Drawable.ConstantState> >(0);
    /*package*/ boolean mPreloading;

    /*package*/ TypedArray mCachedStyledAttributes = null;
+615 −0

File added.

Preview size limit exceeded, changes collapsed.

+11 −5

File changed.

Preview size limit exceeded, changes collapsed.

Loading