Skip to content

Commit

Permalink
Implement findDescendantNode without cloning the tree
Browse files Browse the repository at this point in the history
Differential Revision: D49095341

fbshipit-source-id: 2e6244ad73b64ebf387b498d0ab24990f352cc39
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Sep 11, 2023
1 parent 03fac82 commit aee306c
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ class DummyShadowTreeDelegate : public ShadowTreeDelegate {
inline const ShadowNode* findDescendantNode(
const ShadowNode& shadowNode,
const ShadowNodeFamily& family) {
const ShadowNode* result = nullptr;
shadowNode.cloneTree(family, [&](const ShadowNode& oldShadowNode) {
result = &oldShadowNode;
return oldShadowNode.clone({});
});
return result;
if (&shadowNode.getFamily() == &family) {
return &shadowNode;
}

for (auto childNode : shadowNode.getChildren()) {
auto descendant = findDescendantNode(*childNode, family);
if (descendant != nullptr) {
return descendant;
}
}

return nullptr;
}

inline const ShadowNode* findDescendantNode(
Expand Down

0 comments on commit aee306c

Please sign in to comment.