4 ms·
It has methods and fields, it implements interfaces, and descends from the 'Object' type. The fact that it's unboxed is an implementation detail. https://docs
by lacampbell 7y ago
It has methods and fields, it implements interfaces, and descends from the 'Object' type.
The fact that it's unboxed is an implementation detail.
https://docs.microsoft.com/en-us/dotnet/api/system.int32?view=netframework-4.8 https://docs.microsoft.com/en-us/dotnet/api/system.int32?vie...
- alkonaut 7y agoWhat’s relevant for performance is whether an array of 1000 “things” require 1 or 1001 allocated objects, whether accessing thing N in the array requires dereferencing one or two pointers, and whether the item has a storage of 32 bits without overhead for headers. Which ones to call “objects” is semantics. For efficient access, the array must be a consecutive array of primitives. This is the case in both C# and java for integers. In C# it’s also the case for an array of Vector2 with 2 primitives each, which isn’t the case in java. My point is this: avoid heap allocating many things in collections. They must be raw (primitive, consecutive) data without per instance overhead and of course without heap alloc/GC cost.