3 ms·
> The class check requires loading the object from main memory/cpu cache but the actual check is a single cycle cmp check. Only a guard or, possibly, a final c
by neonsunset 2y ago
> The class check requires loading the object from main memory/cpu cache but the actual check is a single cycle cmp check.
Only a guard or, possibly, a final class type-check (at least it's the case for sealed classes or exact type comparisons in .NET). For anything else this will be more involved due to inheritance.
Obviously for any length above ~3 this won't dominate but JVM type system defaults don't make all this any easier.
- wbl 2y agoI'm not an expert but I think that the compiler requires the exact class on insertion so at use it's just a check.