Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Unified Diff: Source/core/animation/InterpolationEffect.cpp

Issue 732153003: Update a result vector when sampling animation effects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/InterpolationEffect.h ('k') | Source/core/animation/InterpolationEffectTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/InterpolationEffect.cpp
diff --git a/Source/core/animation/InterpolationEffect.cpp b/Source/core/animation/InterpolationEffect.cpp
index b2db74a1a4f98f348a282cb3abe4aa17bbf80564..900036a06ec18d6dda6413ecf4d5f34793178e3f 100644
--- a/Source/core/animation/InterpolationEffect.cpp
+++ b/Source/core/animation/InterpolationEffect.cpp
@@ -7,10 +7,13 @@
namespace blink {
-PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > InterpolationEffect::getActiveInterpolations(double fraction, double iterationDuration) const
+void InterpolationEffect::getActiveInterpolations(double fraction, double iterationDuration, OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>& result) const
{
+ if (!result)
+ result = adoptPtrWillBeNoop(new WillBeHeapVector<RefPtrWillBeMember<Interpolation> >());
- WillBeHeapVector<RefPtrWillBeMember<Interpolation> >* result = new WillBeHeapVector<RefPtrWillBeMember<Interpolation> >();
+ size_t existingSize = result->size();
+ size_t resultIndex = 0;
for (size_t i = 0; i < m_interpolations.size(); ++i) {
const InterpolationRecord* record = m_interpolations[i].get();
@@ -20,11 +23,14 @@ PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > In
if (record->m_easing)
localFraction = record->m_easing->evaluate(localFraction, accuracyForDuration(iterationDuration));
interpolation->interpolate(0, localFraction);
- result->append(interpolation);
+ if (resultIndex < existingSize)
+ (*result)[resultIndex++] = interpolation;
+ else
+ result->append(interpolation);
}
}
-
- return adoptPtrWillBeNoop(result);
+ if (resultIndex < existingSize)
+ result->shrink(resultIndex);
}
void InterpolationEffect::InterpolationRecord::trace(Visitor* visitor)
« no previous file with comments | « Source/core/animation/InterpolationEffect.h ('k') | Source/core/animation/InterpolationEffectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698