Loading core/java/android/animation/Animator.java +6 −9 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.os.Build; import android.util.LongArray; import java.util.ArrayList; import java.util.concurrent.atomic.AtomicReference; /** * This is the superclass for classes which provide basic support for animations which can be Loading Loading @@ -76,7 +77,7 @@ public abstract class Animator implements Cloneable { * of it in case the list is modified while iterating. The array can be reused to avoid * allocation on every notification. */ private Object[] mCachedList; private AtomicReference<Object[]> mCachedList = new AtomicReference<>(); /** * Tracks whether we've notified listeners of the onAnimationStart() event. This can be Loading Loading @@ -452,7 +453,7 @@ public abstract class Animator implements Cloneable { if (mPauseListeners != null) { anim.mPauseListeners = new ArrayList<AnimatorPauseListener>(mPauseListeners); } anim.mCachedList = null; anim.mCachedList.set(null); anim.mStartListenersCalled = false; return anim; } catch (CloneNotSupportedException e) { Loading Loading @@ -654,13 +655,9 @@ public abstract class Animator implements Cloneable { int size = list == null ? 0 : list.size(); if (size > 0) { // Try to reuse mCacheList to store the items of list. Object[] array; if (mCachedList == null || mCachedList.length < size) { Object[] array = mCachedList.getAndSet(null); if (array == null || array.length < size) { array = new Object[size]; } else { array = mCachedList; // Clear it in case there is some reentrancy mCachedList = null; } list.toArray(array); for (int i = 0; i < size; i++) { Loading @@ -670,7 +667,7 @@ public abstract class Animator implements Cloneable { array[i] = null; } // Store it for the next call so we can reuse this array, if needed. mCachedList = array; mCachedList.compareAndSet(null, array); } } Loading Loading
core/java/android/animation/Animator.java +6 −9 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.os.Build; import android.util.LongArray; import java.util.ArrayList; import java.util.concurrent.atomic.AtomicReference; /** * This is the superclass for classes which provide basic support for animations which can be Loading Loading @@ -76,7 +77,7 @@ public abstract class Animator implements Cloneable { * of it in case the list is modified while iterating. The array can be reused to avoid * allocation on every notification. */ private Object[] mCachedList; private AtomicReference<Object[]> mCachedList = new AtomicReference<>(); /** * Tracks whether we've notified listeners of the onAnimationStart() event. This can be Loading Loading @@ -452,7 +453,7 @@ public abstract class Animator implements Cloneable { if (mPauseListeners != null) { anim.mPauseListeners = new ArrayList<AnimatorPauseListener>(mPauseListeners); } anim.mCachedList = null; anim.mCachedList.set(null); anim.mStartListenersCalled = false; return anim; } catch (CloneNotSupportedException e) { Loading Loading @@ -654,13 +655,9 @@ public abstract class Animator implements Cloneable { int size = list == null ? 0 : list.size(); if (size > 0) { // Try to reuse mCacheList to store the items of list. Object[] array; if (mCachedList == null || mCachedList.length < size) { Object[] array = mCachedList.getAndSet(null); if (array == null || array.length < size) { array = new Object[size]; } else { array = mCachedList; // Clear it in case there is some reentrancy mCachedList = null; } list.toArray(array); for (int i = 0; i < size; i++) { Loading @@ -670,7 +667,7 @@ public abstract class Animator implements Cloneable { array[i] = null; } // Store it for the next call so we can reuse this array, if needed. mCachedList = array; mCachedList.compareAndSet(null, array); } } Loading