Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: props are no longer unnecesarily copied in new architecture #2163

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions apple/Utils/RNSVGFabricConversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#import <React/RCTFabricComponentsPlugins.h>

template <typename T>
RNSVGBrush *brushFromColorStruct(T fillObject)
RNSVGBrush *brushFromColorStruct(const T &fillObject)
{
int type = fillObject.type;

Expand Down Expand Up @@ -43,7 +43,7 @@ RNSVGBrush *brushFromColorStruct(T fillObject)
}

template <typename T>
void setCommonNodeProps(T nodeProps, RNSVGNode *node)
void setCommonNodeProps(const T &nodeProps, RNSVGNode *node)
{
node.name = RCTNSStringFromStringNilIfEmpty(nodeProps.name);
node.opacity = nodeProps.opacity;
Expand Down Expand Up @@ -87,7 +87,7 @@ void setCommonNodeProps(T nodeProps, RNSVGNode *node)
node.accessibilityLabel = RCTNSStringFromStringNilIfEmpty(nodeProps.accessibilityLabel);
}

static NSMutableArray<RNSVGLength *> *createLengthArrayFromStrings(std::vector<std::string> stringArray)
static NSMutableArray<RNSVGLength *> *createLengthArrayFromStrings(const std::vector<std::string> &stringArray)
{
if (stringArray.empty()) {
return nil;
Expand All @@ -101,7 +101,7 @@ static NSMutableArray<RNSVGLength *> *createLengthArrayFromStrings(std::vector<s
}

template <typename T>
void setCommonRenderableProps(T renderableProps, RNSVGRenderable *renderableNode)
void setCommonRenderableProps(const T &renderableProps, RNSVGRenderable *renderableNode)
{
setCommonNodeProps(renderableProps, renderableNode);
renderableNode.fill = brushFromColorStruct(renderableProps.fill);
Expand Down Expand Up @@ -132,7 +132,7 @@ void setCommonRenderableProps(T renderableProps, RNSVGRenderable *renderableNode
}
}

static void addValueToDict(NSMutableDictionary *dict, std::string value, NSString *key)
static void addValueToDict(NSMutableDictionary *dict, const std::string &value, NSString *key)
{
NSString *valueOrNil = RCTNSStringFromStringNilIfEmpty(value);
if (valueOrNil) {
Expand All @@ -141,7 +141,7 @@ static void addValueToDict(NSMutableDictionary *dict, std::string value, NSStrin
}

template <typename T>
NSDictionary *parseFontStruct(T fontStruct)
NSDictionary *parseFontStruct(const T &fontStruct)
{
NSMutableDictionary *fontDict = [NSMutableDictionary new];

Expand All @@ -164,7 +164,7 @@ NSDictionary *parseFontStruct(T fontStruct)
}

template <typename T>
void setCommonGroupProps(T groupProps, RNSVGGroup *groupNode)
void setCommonGroupProps(const T &groupProps, RNSVGGroup *groupNode)
{
setCommonRenderableProps(groupProps, groupNode);

Expand All @@ -183,7 +183,7 @@ void setCommonGroupProps(T groupProps, RNSVGGroup *groupNode)
}

template <typename T>
void setCommonTextProps(T textProps, RNSVGText *textNode)
void setCommonTextProps(const T &textProps, RNSVGText *textNode)
{
setCommonGroupProps(textProps, textNode);
textNode.deltaX = createLengthArrayFromStrings(textProps.dx);
Expand Down
Loading