> On Mar 2, 2015, at 10:51 AM, Jeff Kelley <[email protected]> wrote: > > Aren’t NSNumbers now created as tagged pointers when possible? That doesn’t > cover 100% of the difference between C arrays and NSArray, but it would be a > huge portion of it.
Yes, but we don’t know which numbers result in a tagged pointer and which allocate memory; that’s an implementation detail. I know that in 32-bit processes only small integers can be stored inside pointers. In 64-bit there’s a lot more room, of course. It’s possible that 32-bit integers and floats could be stored that way, although of course not doubles. In that case, operations on these arrays would be “only” about 20-50x slower than a C array. Accessing an array element would take two trips through objc_msgsend, some array range checking, and some bit-twiddling to extract the number out of the pointer. Versus one indirect-access register load instruction for a C array. (A C++ vector is probably the same as C once all the template goop gets inlined away; maybe a handful more instructions if vectors do range checking.) —Jens
_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com This email sent to [email protected]
