-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Reland arc cf2 (Draft for discussion) #38255
Conversation
…et to ARC flutter#37049" (flutter#37219)" (flutter#37320)" This reverts commit cf22fc2.
UInt32 length = [self readSize]; | ||
NSMutableArray* array = [NSMutableArray arrayWithCapacity:length]; | ||
UInt32 length = [codec readSize]; | ||
CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, length, &kCFTypeArrayCallBacks); |
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.
If you want to minimize the diff you could say:
CFMutableArrayRef array = (__bridge CFMutableArrayRef)[NSMutableArray arrayWithCapacity:length];
Then remove the CFAutorelease
below.
Same thing for the dictionary below.
_range.length = length; | ||
NSData* data = [_data subdataWithRange:_range]; | ||
_range.location += _range.length; | ||
return data; | ||
// return (CFDataRef)CFAutorelease((__bridge CFDataRef)data); | ||
return (CFDataRef)CFRetain((__bridge CFDataRef)data); |
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.
So data
is already on the autorelease pool here. You should just return it directly with the bridge cast.
return (__bridge CFDataRef)data;
} | ||
|
||
- (NSString*)readUTF8 { | ||
NSData* bytes = [self readData:[self readSize]]; | ||
return [[NSString alloc] initWithData:bytes encoding:NSUTF8StringEncoding]; | ||
CFDataRef bytes = (CFDataRef)[self readDataRef:[self readSize]]; |
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.
No need for a cast here.
NSData* bytes = [self readData:[self readSize]]; | ||
return [[NSString alloc] initWithData:bytes encoding:NSUTF8StringEncoding]; | ||
CFDataRef bytes = (CFDataRef)[self readDataRef:[self readSize]]; | ||
NSData *data = (NSData*)CFBridgingRelease(bytes); |
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 do you do CFBridgingRelease
here instead of just using (__bridge)
? bytes
is already on the autorelease pool and initWithData:encoding:
should retain it. There's no need to involve ARC. That's what we are trying to avoid =)
@cyanglaz can this be closed? |
This is a draft for discussion only. The result will be cooperated in #37883.