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

Commit 9b80ca81 authored by Chet Haase's avatar Chet Haase
Browse files

Optimize calls to Trace for animators

Previously, ValueAnimator would always call into the Trace class to
log start/end events. When the animator is an ObjectAnimator, this
call necessitated building a new String to capture the animated property
name. This fix puts the calls to Trace inside a check for isTagEnabled(),
to ensure that we only bother building the trace name when tracing is
actually enabled.

Change-Id: I56ef093f3b67b31a19c861f9d1e44a84341edf53
parent aca7d39d
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -1024,17 +1024,21 @@ public class ValueAnimator extends Animator {
        mStarted = false;
        mStartListenersCalled = false;
        mPlayingBackwards = false;
        if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
            Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW, getNameForTrace(),
                    System.identityHashCode(this));
        }
    }

    /**
     * Called internally to start an animation by adding it to the active animations list. Must be
     * called on the UI thread.
     */
    private void startAnimation(AnimationHandler handler) {
        if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
            Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW, getNameForTrace(),
                    System.identityHashCode(this));
        }
        initAnimation();
        handler.mAnimations.add(this);
        if (mStartDelay > 0 && mListeners != null) {