-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[iOS] Fabric: Add missing source properties of Image #46460
[iOS] Fabric: Add missing source properties of Image #46460
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this!
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There have been some feedback internally on the change, to improve this.
Could you please have a look at them and apply them?
packages/react-native/ReactCommon/react/renderer/components/image/conversions.h
Outdated
Show resolved
Hide resolved
method = [[NSString alloc] initWithBytesNoCopy:(void *)imageSource.method.c_str() | ||
length:imageSource.method.size() | ||
encoding:NSUTF8StringEncoding | ||
freeWhenDone:NO] | ||
.uppercaseString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why can't we just do?
method = [[NSString alloc] initWithBytesNoCopy:(void *)imageSource.method.c_str() | |
length:imageSource.method.size() | |
encoding:NSUTF8StringEncoding | |
freeWhenDone:NO] | |
.uppercaseString | |
method = [[NSString alloc] initWithUTF8String:imageSource.method.c_str()].uppercaseString; |
also, no need for the ?:
fallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emm, I used no copy
method because I think it can reduce one copy, if we use initWithUTF8String
, it would produces twice copy operations from c_str to nsadata.
...nderer/imagemanager/platform/ios/react/renderer/imagemanager/RCTImagePrimitivesConversions.h
Outdated
Show resolved
Hide resolved
length:imageSource.body.size() | ||
encoding:NSUTF8StringEncoding | ||
freeWhenDone:NO]; | ||
body = [RCTConvert NSData:bodyString]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we just initialize it with some NSData
initializer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems no suitable initializer...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the initializer should be:
[NSData dataWithBytes:imageSource.body.c_str() length:imageSource.body.size()]
We use this also in other locations, like here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cipolleschi I updated. But they are maybe different when bytes are not a valid UTF-8 bytes?
...nderer/imagemanager/platform/ios/react/renderer/imagemanager/RCTImagePrimitivesConversions.h
Outdated
Show resolved
Hide resolved
packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h
Outdated
Show resolved
Hide resolved
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment in NSData initializer
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cipolleschi merged this pull request in 052def0. |
This pull request was successfully merged by @zhongwuzw in 052def0 When will my fix make it into a release? | How to file a pick request? |
Summary:
Fabric: Add missing source properties of Image
Changelog:
[IOS] [FIXED] - Fabric: Add missing source properties of Image
Test Plan:
Missing props should worked.