Re: speed of alloc/init for NSNumber
Re: speed of alloc/init for NSNumber
- Subject: Re: speed of alloc/init for NSNumber
- From: Daryn <email@hidden>
- Date: Sun, 18 Jan 2004 15:49:29 -0600
On Jan 18, 2004, at 3:25 PM, Chuck Soper wrote:
>
At 10:08 PM +0100 1/18/04, Nat! wrote:
>
> Am 18.01.2004 um 21:54 schrieb Chuck Soper:
>
>> Hello,
>
>> I have an NSTableView with about 400 rows and four columns.
>
> ...
>
>> Should I use NSMutableData to avoid all the alloc/init messages to
>
>> NSNumber to speed up my code?
>
> With only 400 rows you needn't worry about the speed of NSNumber
>
> creation.
>
It makes sense that I don't need to worry about speed with only four
>
hundred rows. It just seems like good practice to avoid or minimize
>
allocating memory in any loop. I have three or four other dictionary
>
keys that also require release and alloc/inits messages to be sent.
>
Also, I have another table that I'm about to start working on that
>
will have 25 to 40 thousand rows. I'm wondering at what point I need
>
to worry about the speed of these release and alloc/inits messages.
I personally think everyone should always be concerned by speed. There
is certainly a cost to needless messages, particularly
alloc/init/release. It's taxing to both the cpu and memory allocators,
which is readily apparent on older/slower machines. Optimization
shouldn't be taken to an extreme too early, but avoiding this trio of
messages is almost always a win.
That being said, I have been dismayed by the absence of certain mutable
classes. In the case of NSNumber, I usually use a custom class that
holds the number. Use KVC to fetch the float as a NSValue.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.