diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 2467b5fa7f7..35a54922e77 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -340,7 +340,7 @@ bool LayoutAnimationKeyFrameManager::shouldOverridePullTransaction() const { void LayoutAnimationKeyFrameManager::stopSurface(SurfaceId surfaceId) { std::lock_guard lock(surfaceIdsToStopMutex_); - surfaceIdsToStop_.push_back(surfaceId); + surfaceIdsToStop_.insert(surfaceId); } bool LayoutAnimationKeyFrameManager::shouldAnimateFrame() const { @@ -756,26 +756,24 @@ LayoutAnimationKeyFrameManager::pullTransaction( // Execute stopSurface on any ongoing animations if (inflightAnimationsExistInitially) { - std::vector surfaceIdsToStop{}; + better::set surfaceIdsToStop{}; { std::lock_guard lock(surfaceIdsToStopMutex_); surfaceIdsToStop = surfaceIdsToStop_; - surfaceIdsToStop_ = {}; + surfaceIdsToStop_.clear(); } for (auto it = inflightAnimations_.begin(); it != inflightAnimations_.end();) { const auto &animation = *it; - if (std::find( - surfaceIdsToStop.begin(), - surfaceIdsToStop.end(), - animation.surfaceId) != surfaceIdsToStop.end()) { #ifdef LAYOUT_ANIMATION_VERBOSE_LOGGING - LOG(ERROR) - << "LayoutAnimations: stopping animation due to stopSurface on " - << surfaceId; + LOG(ERROR) + << "LayoutAnimations: stopping animation due to stopSurface on " + << surfaceId; #endif + if (surfaceIdsToStop.find(animation.surfaceId) != + surfaceIdsToStop.end()) { it = inflightAnimations_.erase(it); } else { it++; diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index eaad96b3abb..d8c629e38be 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -243,7 +244,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, std::vector &conflictingAnimations) const; mutable std::mutex surfaceIdsToStopMutex_; - mutable std::vector surfaceIdsToStop_{}; + mutable better::set surfaceIdsToStop_{}; protected: bool hasComponentDescriptorForShadowView(ShadowView const &shadowView) const;