mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Use set instead of vector to hold stopped surfaces
Summary: changelog: [internal] Use set instead of vector. It makes for nicer API to check if the element exists. Reviewed By: cortinico Differential Revision: D30728211 fbshipit-source-id: 7b7cc1e94bb82a44b064e2945a753adbbce5dc2c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
30887403ec
commit
cb58c84dc0
@@ -340,7 +340,7 @@ bool LayoutAnimationKeyFrameManager::shouldOverridePullTransaction() const {
|
||||
|
||||
void LayoutAnimationKeyFrameManager::stopSurface(SurfaceId surfaceId) {
|
||||
std::lock_guard<std::mutex> 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<SurfaceId> surfaceIdsToStop{};
|
||||
better::set<SurfaceId> surfaceIdsToStop{};
|
||||
{
|
||||
std::lock_guard<std::mutex> 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++;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <ReactCommon/RuntimeExecutor.h>
|
||||
#include <better/optional.h>
|
||||
#include <better/set.h>
|
||||
#include <react/renderer/core/EventTarget.h>
|
||||
#include <react/renderer/core/RawValue.h>
|
||||
#include <react/renderer/debug/flags.h>
|
||||
@@ -243,7 +244,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
|
||||
std::vector<AnimationKeyFrame> &conflictingAnimations) const;
|
||||
|
||||
mutable std::mutex surfaceIdsToStopMutex_;
|
||||
mutable std::vector<SurfaceId> surfaceIdsToStop_{};
|
||||
mutable better::set<SurfaceId> surfaceIdsToStop_{};
|
||||
|
||||
protected:
|
||||
bool hasComponentDescriptorForShadowView(ShadowView const &shadowView) const;
|
||||
|
||||
Reference in New Issue
Block a user