On 15 Jul 2014, at 00:32, Jens Alfke <j...@mooseyard.com> wrote:

> 
> On Jul 14, 2014, at 1:07 PM, Carl Hoefs <newsli...@autonomy.caltech.edu> 
> wrote:
> 
>>    modifiableData = [ NSMutableData dataWithData: [ external call that gives 
>> me an NSData ] ];
> 
> It’s shorter and more idiomatic to just say
>       modifiableData = [external mutableCopy];
> (plus an autorelease if you’re not using ARC)
> 
>> Will get it working first, and if there's a performance panic, perhaps 
>> something can be done (but I extremely doubt it).
> 
> 
> Well, the most optimal thing to do would be to create an empty NSMutableData 
> of the correct size, then use memcpy to copy in the correct pieces from the 
> original NSData and whatever other sources there are. That will save you some 
> unnecessary copies and possibly realloc calls.

Another possibility is to use dispatch_data. Rather than copy bytes around to 
assemble them into a contiguous buffer, your use case might be just as well 
suited to dispatch_data’s approach of tying together various non-contiguous 
buffers.


_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to