Skip to content

Commit

Permalink
Tidy up some loops in SMILTimeContainer::updateAnimations
Browse files Browse the repository at this point in the history
Use for-range style loops and get rid of the local 'size' variable.
Also move the sort() call down after the early-out when there are no
animations to apply.

BUG=641437

Review-Url: https://codereview.chromium.org/2287973002
Cr-Commit-Position: refs/heads/master@{#415165}
  • Loading branch information
fs authored and Commit bot committed Aug 30, 2016
1 parent 4de1fcf commit 887b2bd
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions third_party/WebKit/Source/core/svg/animation/SMILTimeContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,7 @@ SMILTime SMILTimeContainer::updateAnimations(double elapsed, bool seekToTime)
}
m_scheduledAnimations.removeAll(invalidKeys);

std::sort(animationsToApply.begin(), animationsToApply.end(), PriorityCompare(elapsed));

unsigned animationsToApplySize = animationsToApply.size();
if (!animationsToApplySize) {
if (animationsToApply.isEmpty()) {
#if ENABLE(ASSERT)
m_preventScheduledAnimationsChanges = false;
#endif
Expand All @@ -511,26 +508,27 @@ SMILTime SMILTimeContainer::updateAnimations(double elapsed, bool seekToTime)

UseCounter::count(&document(), UseCounter::SVGSMILAnimationAppliedEffect);

std::sort(animationsToApply.begin(), animationsToApply.end(), PriorityCompare(elapsed));

// Apply results to target elements.
for (unsigned i = 0; i < animationsToApplySize; ++i)
animationsToApply[i]->applyResultsToTarget();
for (const auto& timedElement : animationsToApply)
timedElement->applyResultsToTarget();

#if ENABLE(ASSERT)
m_preventScheduledAnimationsChanges = false;
#endif

for (unsigned i = 0; i < animationsToApplySize; ++i) {
if (animationsToApply[i]->isConnected() && animationsToApply[i]->isSVGDiscardElement()) {
SVGSMILElement* animDiscard = animationsToApply[i];
SVGElement* targetElement = animDiscard->targetElement();
for (const auto& timedElement : animationsToApply) {
if (timedElement->isConnected() && timedElement->isSVGDiscardElement()) {
SVGElement* targetElement = timedElement->targetElement();
if (targetElement && targetElement->isConnected()) {
targetElement->remove(IGNORE_EXCEPTION);
ASSERT(!targetElement->isConnected());
DCHECK(!targetElement->isConnected());
}

if (animDiscard->isConnected()) {
animDiscard->remove(IGNORE_EXCEPTION);
ASSERT(!animDiscard->isConnected());
if (timedElement->isConnected()) {
timedElement->remove(IGNORE_EXCEPTION);
DCHECK(!timedElement->isConnected());
}
}
}
Expand Down

0 comments on commit 887b2bd

Please sign in to comment.