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

perf: avoid unnecessary shared_ptr copies in Fabric components #2164

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGClipPath.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGClipPathProps>(props);
const auto &newProps = static_cast<const RNSVGClipPathProps &>(*props);
setCommonNodeProps(newProps, self);
_props = std::static_pointer_cast<RNSVGClipPathProps const>(props);
}
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGForeignObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGForeignObjectProps>(props);
const auto &newProps = static_cast<const RNSVGForeignObjectProps &>(*props);

self.x = RCTNSStringFromStringNilIfEmpty(newProps.x)
? [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)]
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGGroup.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGGroupProps>(props);
const auto &newProps = static_cast<const RNSVGGroupProps &>(*props);

setCommonGroupProps(newProps, self);
_props = std::static_pointer_cast<RNSVGGroupProps const>(props);
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGImageProps>(props);
const auto &newProps = static_cast<const RNSVGImageProps &>(*props);

self.x = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)];
self.y = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y)];
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGLinearGradient.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGLinearGradientProps>(props);
const auto &newProps = static_cast<const RNSVGLinearGradientProps &>(*props);

self.x1 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x1)];
self.y1 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y1)];
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGMarker.mm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGMarkerProps>(props);
const auto &newProps = static_cast<const RNSVGMarkerProps &>(*props);

self.refX = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.refX)];
self.refY = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.refY)];
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGMask.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGMaskProps>(props);
const auto &newProps = static_cast<const RNSVGMaskProps &>(*props);

self.x = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)];
self.y = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y)];
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGPath.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGPathProps>(props);
const auto &newProps = static_cast<const RNSVGPathProps &>(*props);
self.d = [[RNSVGPathParser alloc] initWithPathString:RCTNSStringFromString(newProps.d)];

setCommonRenderableProps(newProps, self);
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGPattern.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGPatternProps>(props);
const auto &newProps = static_cast<const RNSVGPatternProps &>(*props);

self.x = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)];
self.y = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y)];
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGRadialGradient.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGRadialGradientProps>(props);
const auto &newProps = static_cast<const RNSVGRadialGradientProps &>(*props);

self.fx = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.fx)];
self.fy = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.fy)];
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGSvgView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGSvgViewProps>(props);
const auto &newProps = static_cast<const RNSVGSvgViewProps &>(*props);

self.minX = newProps.minX;
self.minY = newProps.minY;
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGSymbol.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGSymbolProps>(props);
const auto &newProps = static_cast<const RNSVGSymbolProps &>(*props);

self.minX = newProps.minX;
self.minY = newProps.minY;
Expand Down
2 changes: 1 addition & 1 deletion apple/Elements/RNSVGUse.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGUseProps>(props);
const auto &newProps = static_cast<const RNSVGUseProps &>(*props);

self.x = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)];
self.y = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y)];
Expand Down
2 changes: 1 addition & 1 deletion apple/Shapes/RNSVGCircle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGCircleProps>(props);
const auto &newProps = static_cast<const RNSVGCircleProps &>(*props);

self.cx = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.cx)];
self.cy = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.cy)];
Expand Down
2 changes: 1 addition & 1 deletion apple/Shapes/RNSVGEllipse.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGEllipseProps>(props);
const auto &newProps = static_cast<const RNSVGEllipseProps &>(*props);

self.cx = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.cx)];
self.cy = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.cy)];
Expand Down
2 changes: 1 addition & 1 deletion apple/Shapes/RNSVGLine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGLineProps>(props);
const auto &newProps = static_cast<const RNSVGLineProps &>(*props);

self.x1 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x1)];
self.y1 = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y1)];
Expand Down
2 changes: 1 addition & 1 deletion apple/Shapes/RNSVGRect.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGRectProps>(props);
const auto &newProps = static_cast<const RNSVGRectProps &>(*props);

self.x = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.x)];
self.y = [RNSVGLength lengthWithString:RCTNSStringFromString(newProps.y)];
Expand Down
2 changes: 1 addition & 1 deletion apple/Text/RNSVGTSpan.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGTSpanProps>(props);
const auto &newProps = static_cast<const RNSVGTSpanProps &>(*props);

self.content = RCTNSStringFromStringNilIfEmpty(newProps.content);

Expand Down
2 changes: 1 addition & 1 deletion apple/Text/RNSVGText.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGTextProps>(props);
const auto &newProps = static_cast<const RNSVGTextProps &>(*props);

setCommonTextProps(newProps, self);
_props = std::static_pointer_cast<RNSVGTextProps const>(props);
Expand Down
2 changes: 1 addition & 1 deletion apple/Text/RNSVGTextPath.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ + (ComponentDescriptorProvider)componentDescriptorProvider

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
const auto &newProps = *std::static_pointer_cast<const RNSVGTextPathProps>(props);
const auto &newProps = static_cast<const RNSVGTextPathProps &>(*props);

self.href = RCTNSStringFromStringNilIfEmpty(newProps.href);
self.side = RCTNSStringFromStringNilIfEmpty(newProps.side);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ class RNSVGImageComponentDescriptor final
void adopt(ShadowNode::Unshared const &shadowNode) const override {
ConcreteComponentDescriptor::adopt(shadowNode);

auto imageShadowNode =
std::static_pointer_cast<RNSVGImageShadowNode>(shadowNode);
auto &imageShadowNode = static_cast<RNSVGImageShadowNode &>(*shadowNode);

// `RNSVGImageShadowNode` uses `ImageManager` to initiate image loading and
// communicate the loading state and results to mounting layer.
imageShadowNode->setImageManager(imageManager_);
imageShadowNode.setImageManager(imageManager_);
}

private:
Expand Down
Loading