3 ms·
For .NET devs: Always use something that implements IList instead of a primitive array. As Eric points out, you can make it read-only and avoid the malloc frenz
by Aaronontheweb 16y ago
For .NET devs: Always use something that implements IList instead of a primitive array. As Eric points out, you can make it read-only and avoid the malloc frenzy that occurs under the hood when you work with methods that return primitive arrays.
You can also inherit from any of the IList / IEnumerable / ICollection types and make customizations to better support parallelism, memory usage, etc... I've done implementations on top of IQueue (a cousin of IList) before to support custom Reader/Writer scenarios for a parallelized polling service (in-memory job queue) and it worked well.