Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Maybe the first value is much larger? apart from CoreFoundation's CFNumber caching, the "new" runtime uses tagged pointers, allowing integers within the range of 24 bit to be encoded directly into the pointer - the runtime then figure out it's a tagged pointer by looking at the last bit (and that its a CFNumber by looking at the 3 bits before the last bit and the target number size - 8, 16, 32, 64 bit - using the next 4 bits before). <br/>On a 32-bit system (current iPhones), that means that for ("small") negative 32 bit numbers or large positive numbers, CoreFoundation will allocate an object. For everything else, it uses the following expression that is way faster:</p> <pre><code> case kCFNumberSInt32Type: { int32_t value = *(int32_t *)valuePtr; // this loads the actual numerical value passed to CFNumberCreate() #if !__LP64__ // We don't bother allowing the min 24-bit integer -2^23 to also be fast-pathed; // tell anybody that complains about that to go ... hang. int32_t limit = (1L &lt;&lt; 23); if (value &lt;= -limit || limit &lt;= value) break; #endif uintptr_t ptr_val = ((uintptr_t)((intptr_t)value &lt;&lt; 8) | (2 &lt;&lt; 6) | kCFTaggedObjectID_Integer); return (CFNumberRef)ptr_val; } </code></pre> <p>(note that <code>!__LP64__</code> is true for 32-bit systems)</p> <p>Taken from: <a href="http://www.opensource.apple.com/source/CF/CF-744.12/CFNumber.c" rel="nofollow">http://www.opensource.apple.com/source/CF/CF-744.12/CFNumber.c</a></p> <p><p></p> <p>Also, there is a caching mechanism that prevents a range of numbers from being re-created multiple times, just search for "__CFNumberCache" in the same source file.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload