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


Dave
 

Hi,

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

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?

All the Best
Dave

On 
On 22 Aug 2017, at 17:47, Jens Alfke <jens@...> wrote:


On Aug 18, 2017, at 2:38 PM, Alex Zavatone <zav@...> wrote:

In that light, is my suggestion useless overhead?

(IIRC you suggested using an NSMutableArray of NSNumbers?) Honestly, it depends. It does have overhead, although not as much as it used to, since NSNumbers of reasonable-size integers don't allocate any memory (they're just tagged pointers.) On the plus side, you get array bounds checking, and it's easy to grow the array dynamically if you ever need to.

If you don't need high performance (e.g. you're not doing math-y stuff with these arrays) and you're not allocating millions of these, NSMutableArray is reasonable. Especially for those who aren't super comfortable with C.

—Jens

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