Last active
August 29, 2015 13:59
-
-
Save steipete/10621374 to your computer and use it in GitHub Desktop.
Testing "if you use a default allocator, and default callbacks, CF will generate an NS collection instead". (https://twitter.com/Catfish_Man/status/455592839334723584). We currently only have that on Mavericks, but since it the same codebase I'm 100% sure this will be in iOS 8 as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code using the default allocator and callbacks now actually returns an NSArray (__NSArrayM), and no longer a toll-free-bridged object. | |
NSArray *test = CFBridgingRelease(CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); | |
NSArray *test3 = CFBridgingRelease(CFArrayCreate(kCFAllocatorDefault, NULL, 0, &kCFTypeArrayCallBacks)); | |
// This is custom and will always return __NSCFArray | |
NSArray *test2 = CFBridgingRelease(CFArrayCreateMutable(kCFAllocatorDefault, 0, NULL)); | |
// This will return __NSArrayI. | |
NSArray *test4 = [NSArray array]; | |
/* | |
lldb (Mavericks, 10.9.2) | |
(lldb) po test | |
<__NSArrayM 0x10010ea80>( | |
) | |
(lldb) po test2 | |
<__NSCFArray 0x10010ed50>( | |
) | |
(lldb) po test3 | |
<__NSArrayI 0x100103fd0>( | |
) | |
(lldb) po test4 | |
<__NSArrayI 0x100103fd0>( | |
) | |
lldb (iOS 7.1, Simulator): | |
(lldb) po test | |
<__NSCFArray 0x113f04720>( | |
) | |
(lldb) po test2 | |
<__NSCFArray 0x113f04750>( | |
) | |
(lldb) po test3 | |
<__NSCFArray 0x113f04780>( | |
) | |
(lldb) po test4 | |
<__NSArrayI 0x10e232820>( | |
) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TIL: The old “use CF because it’s faster” thing was arguably not true before, but very much so isn’t now. Hah. Looks like we've some things to do in http://pspdfkit.com. We're using CF extensively for performance reasons (especially for the glyph text parsing), which was very much important for iOS 4-6, but less so for 7 and might even negate in iOS 8.
This might be enabled for a future version of iOS since the objc_msgSend overhead is negligible in the arm64 runtime