summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chet Haase <chet@google.com> 2013-06-04 09:37:38 -0700
committer Chet Haase <chet@google.com> 2013-06-04 09:37:38 -0700
commit9b80ca81a8cc33067d858c52c7acbef9d8bdaf6a (patch)
tree6003d3e125eb127869ac7f8baf35360045fc5dfa
parentaca7d39d087741f7e88e012db95ad961f9f08955 (diff)
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
-rw-r--r--core/java/android/animation/ValueAnimator.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index f8ae616501bb..e370e4aff985 100644
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -1024,8 +1024,10 @@ public class ValueAnimator extends Animator {
mStarted = false;
mStartListenersCalled = false;
mPlayingBackwards = false;
- Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW, getNameForTrace(),
- System.identityHashCode(this));
+ if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
+ Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW, getNameForTrace(),
+ System.identityHashCode(this));
+ }
}
/**
@@ -1033,8 +1035,10 @@ public class ValueAnimator extends Animator {
* called on the UI thread.
*/
private void startAnimation(AnimationHandler handler) {
- Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW, getNameForTrace(),
- System.identityHashCode(this));
+ 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) {