Skip to content

Commit 93f537f

Browse files
committed
Get rid of collectProps call
1 parent db291cc commit 93f537f

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

packages/react-native-reanimated/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,39 @@ void AnimatedPropsRegistry::remove(const Tag tag) {
3333
}
3434

3535
jsi::Value AnimatedPropsRegistry::getUpdatesOlderThanTimestamp(jsi::Runtime &rt, const double timestamp) {
36-
std::set<Tag> viewTags;
36+
std::unordered_map<Tag, folly::dynamic> updatesMap;
37+
3738
{
3839
auto lock1 = lock();
40+
41+
std::set<Tag> viewTags;
3942
for (const auto &[viewTag, viewTimestamp] : timestampMap_) {
4043
if (viewTimestamp < timestamp) {
4144
viewTags.insert(viewTag);
4245
}
4346
}
44-
}
4547

46-
PropsMap propsMap;
47-
collectProps(propsMap); // TODO: don't call collectProps since it locks again
48-
49-
const jsi::Array array(rt, viewTags.size());
50-
size_t idx = 0;
51-
for (const auto &[family, vectorOfRawProps] : propsMap) {
52-
const auto viewTag = family->getTag();
53-
if (!viewTags.contains(viewTag)) {
54-
continue;
55-
}
48+
for (const auto &[tag, pair] : updatesRegistry_) {
49+
const auto &[shadowNode, props] = pair;
50+
const auto viewTag = shadowNode->getTag();
51+
if (!viewTags.contains(viewTag)) {
52+
continue;
53+
}
5654

57-
folly::dynamic styleProps = folly::dynamic::object();
58-
for (const auto &rawProps : vectorOfRawProps) {
59-
styleProps.update(static_cast<folly::dynamic>(rawProps));
55+
auto it = updatesMap.find(viewTag);
56+
if (it == updatesMap.cend()) {
57+
folly::dynamic styleProps = folly::dynamic::object();
58+
styleProps.update(props);
59+
updatesMap[viewTag] = styleProps;
60+
} else {
61+
it->second.update(props);
62+
}
6063
}
64+
}
6165

66+
const jsi::Array array(rt, updatesMap.size());
67+
size_t idx = 0;
68+
for (const auto &[viewTag, styleProps] : updatesMap) {
6269
const jsi::Object item(rt);
6370
item.setProperty(rt, "viewTag", viewTag);
6471
item.setProperty(rt, "styleProps", jsi::valueFromDynamic(rt, styleProps));

0 commit comments

Comments
 (0)