Re: How to store C Arrays as a Property or iVar?


 



On Aug 23, 2017, at 3:28 AM, Dave <dave@...> wrote:

It recurses through the cells in the Array and there could be around 7000 iterations, so I’d rather stick with normal integers.

The time to read and unwrap an integer from an NSArray is probably under a microsecond, so it's unlikely to be a performance problem.

But there's nothing wrong with using a C array. It's what I'd do, personally.

One thing I was going to ask is that, the value range on each cell is 0 to 10, at the moment its using an “int” to hold this (which I assume is 32 bits), would there be a speed impact if I made it int16 or int8?

Yes, because the array will be smaller so it will take up less space in the CPU cache, causing fewer cache misses. But here the difference will be a few nanoseconds.

—Jens

Join {cocoa@apple-dev.groups.io to automatically receive all group messages.