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

Commit 142ff6cd authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Reduce extra invocation of ThreadLocal in AnimationHandler

Eliminate redundant ThreadLocal#get by using modern way to initialize.

Bug: 163976519
Flag: EXEMPT simple refactor
Test: atest ValueAnimatorTests
Change-Id: I46074627ba227e91881d49f7e77f00a0690fea75
parent 40aa32b3
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -110,7 +110,8 @@ public class AnimationHandler {
        }
    };

    public final static ThreadLocal<AnimationHandler> sAnimatorHandler = new ThreadLocal<>();
    public static final ThreadLocal<AnimationHandler> sAnimatorHandler =
            ThreadLocal.withInitial(AnimationHandler::new);
    private static AnimationHandler sTestHandler = null;
    private boolean mListDirty = false;

@@ -118,9 +119,6 @@ public class AnimationHandler {
        if (sTestHandler != null) {
            return sTestHandler;
        }
        if (sAnimatorHandler.get() == null) {
            sAnimatorHandler.set(new AnimationHandler());
        }
        return sAnimatorHandler.get();
    }