mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-06 07:06:11 +00:00
perf: avoid unnecessary shared_ptr copies in Fabric components (#2164)
Ports the upstream best-practice around props handling of shared_ptr in a855013fc6
This commit is contained in:
@@ -39,7 +39,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)]
|
||||
|
||||
@@ -43,7 +43,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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);
|
||||
|
||||
@@ -72,7 +72,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)];
|
||||
|
||||
@@ -40,7 +40,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)];
|
||||
|
||||
@@ -42,7 +42,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)];
|
||||
|
||||
@@ -41,7 +41,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)];
|
||||
|
||||
@@ -41,7 +41,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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);
|
||||
|
||||
@@ -41,7 +41,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)];
|
||||
|
||||
@@ -38,7 +38,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)];
|
||||
|
||||
@@ -64,7 +64,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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;
|
||||
|
||||
@@ -39,7 +39,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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;
|
||||
|
||||
@@ -40,7 +40,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)];
|
||||
|
||||
@@ -40,7 +40,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)];
|
||||
|
||||
@@ -40,7 +40,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)];
|
||||
|
||||
@@ -40,7 +40,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)];
|
||||
|
||||
@@ -40,7 +40,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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)];
|
||||
|
||||
@@ -58,7 +58,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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);
|
||||
|
||||
@@ -39,7 +39,7 @@ using namespace facebook::react;
|
||||
|
||||
- (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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user