On 08.05.2011, at 09:39, Mariano Martinez Peck wrote:
On Sun, May 8, 2011 at 6:54 AM, Eliot Miranda eliot.miranda@gmail.com wrote:
Determining the class of an instance of a compact class is faster than determining the class of an instance of a non-compact class if the compact class index is known.
This is what I don't understand. Even if the compact class index is known, why is it that faster than non-compact? because in non-compact you need to fetch the class pointer from the object header? But... regardless that the compact class index is know, you also have to get the index (those 5 bits) from the OH. So I don't see why there is so much difference in performance.
The difference is that the index can be compared to a *constant*. If the index is 6 (or is it 5?) then this is a Float instance. No matter where in memory the Float class actually is. It's almost like a tag bit for classes, similar to the tag bit to distinguish immediate SmallIntegers.
- Bert -