On Aug 8, 2009, at 3:45 PM, Eric Hermanson wrote:

1. Is it more efficient to malloc a uint8_t array and call NSData 'init no copy', rather than pass in an array allocated with a fixed length on the stack to the init method that makes a copy of the bytes?

If you need to allocate larger amounts of memory than what is typically available on the stack, then you should always do the former. Otherwise, you ought to try doing both and just go with what Shark tells you is fastest. Complete this sentence: Premature optimization is...

2. Does NSMutableData's implementation simply just cast it's internal bytes to const in the 'bytes' method, or does it internally copy the bytes into a new autoreleased NSData and return the 'bytes' for that copy, for example?

What are you trying to accomplish? If you're trying to modify the data's contents, then use -mutableBytes instead.

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to