diff --git a/ReactCommon/fabric/attributedstring/AttributedString.cpp b/ReactCommon/fabric/attributedstring/AttributedString.cpp index 67d2e78258a..4882e23a9a6 100644 --- a/ReactCommon/fabric/attributedstring/AttributedString.cpp +++ b/ReactCommon/fabric/attributedstring/AttributedString.cpp @@ -70,7 +70,7 @@ void AttributedString::prependAttributedString( attributedString.fragments_.end()); } -const std::vector &AttributedString::getFragments() const { +const Fragments &AttributedString::getFragments() const { return fragments_; } diff --git a/ReactCommon/fabric/attributedstring/AttributedString.h b/ReactCommon/fabric/attributedstring/AttributedString.h index 6fc1abc2533..f8fe6a1ceb8 100644 --- a/ReactCommon/fabric/attributedstring/AttributedString.h +++ b/ReactCommon/fabric/attributedstring/AttributedString.h @@ -44,7 +44,7 @@ class AttributedString : public Sealable, public DebugStringConvertible { bool operator!=(const Fragment &rhs) const; }; - using Fragments = std::vector; + using Fragments = better::small_vector; /* * Appends and prepends a `fragment` to the string. diff --git a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp index 60871c120a2..7886204ffef 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp @@ -90,7 +90,7 @@ void YogaLayoutableShadowNode::appendChild(YogaLayoutableShadowNode *child) { } void YogaLayoutableShadowNode::setChildren( - std::vector children) { + YogaLayoutableShadowNode::UnsharedList children) { yogaNode_.setChildren({}); for (const auto &child : children) { appendChild(child); @@ -139,9 +139,9 @@ void YogaLayoutableShadowNode::layoutChildren(LayoutContext layoutContext) { } } -std::vector +LayoutableShadowNode::UnsharedList YogaLayoutableShadowNode::getLayoutableChildNodes() const { - std::vector yogaLayoutableChildNodes; + LayoutableShadowNode::UnsharedList yogaLayoutableChildNodes; yogaLayoutableChildNodes.reserve(yogaNode_.getChildren().size()); for (const auto &childYogaNode : yogaNode_.getChildren()) { diff --git a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h index 8386937ac1e..ea388e39ba7 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h +++ b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.h @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace facebook { @@ -24,6 +25,10 @@ class YogaLayoutableShadowNode : public LayoutableShadowNode, public virtual DebugStringConvertible, public virtual Sealable { public: + using UnsharedList = better::small_vector< + YogaLayoutableShadowNode *, + kShadowNodeChildrenSmallVectorSize>; + #pragma mark - Constructors YogaLayoutableShadowNode(); @@ -51,7 +56,7 @@ class YogaLayoutableShadowNode : public LayoutableShadowNode, * instances. Complements `ShadowNode::setChildren(...)` functionality from * Yoga perspective. */ - void setChildren(std::vector children); + void setChildren(YogaLayoutableShadowNode::UnsharedList children); /* * Sets Yoga styles based on given `YogaStylableProps`. @@ -75,7 +80,7 @@ class YogaLayoutableShadowNode : public LayoutableShadowNode, void layoutChildren(LayoutContext layoutContext) override; - std::vector getLayoutableChildNodes() const override; + LayoutableShadowNode::UnsharedList getLayoutableChildNodes() const override; protected: /* diff --git a/ReactCommon/fabric/core/layout/LayoutableShadowNode.h b/ReactCommon/fabric/core/layout/LayoutableShadowNode.h index 58b767443ea..9a4fc4f31cc 100644 --- a/ReactCommon/fabric/core/layout/LayoutableShadowNode.h +++ b/ReactCommon/fabric/core/layout/LayoutableShadowNode.h @@ -12,8 +12,10 @@ #include #include +#include #include #include +#include #include namespace facebook { @@ -28,6 +30,9 @@ struct LayoutContext; */ class LayoutableShadowNode : public virtual Sealable { public: + using UnsharedList = better:: + small_vector; + virtual ~LayoutableShadowNode() noexcept = default; /* @@ -97,7 +102,7 @@ class LayoutableShadowNode : public virtual Sealable { /* * Returns layoutable children to interate on. */ - virtual std::vector getLayoutableChildNodes() + virtual LayoutableShadowNode::UnsharedList getLayoutableChildNodes() const = 0; /* diff --git a/ReactCommon/fabric/core/shadownode/ConcreteShadowNode.h b/ReactCommon/fabric/core/shadownode/ConcreteShadowNode.h index ef975302152..ae0f04f1ab6 100644 --- a/ReactCommon/fabric/core/shadownode/ConcreteShadowNode.h +++ b/ReactCommon/fabric/core/shadownode/ConcreteShadowNode.h @@ -90,8 +90,12 @@ class ConcreteShadowNode : public ShadowNode { * Returns subset of children that are inherited from `SpecificShadowNodeT`. */ template - std::vector getChildrenSlice() const { - std::vector children; + better:: + small_vector + getChildrenSlice() const { + better:: + small_vector + children; for (const auto &childShadowNode : getChildren()) { auto specificChildShadowNode = dynamic_cast(childShadowNode.get()); diff --git a/ReactCommon/fabric/mounting/ShadowView.h b/ReactCommon/fabric/mounting/ShadowView.h index f343c5aac1f..a45353c30ac 100644 --- a/ReactCommon/fabric/mounting/ShadowView.h +++ b/ReactCommon/fabric/mounting/ShadowView.h @@ -5,6 +5,7 @@ #pragma once +#include #include #include #include @@ -59,7 +60,8 @@ struct ShadowViewNodePair final { bool operator!=(const ShadowViewNodePair &rhs) const; }; -using ShadowViewNodePairList = std::vector; +using ShadowViewNodePairList = better:: + small_vector; } // namespace react } // namespace facebook