Re: [NSMutableData resetDataRangeTo:(NSRange)range];
Re: [NSMutableData resetDataRangeTo:(NSRange)range];
- Subject: Re: [NSMutableData resetDataRangeTo:(NSRange)range];
- From: Jens Alfke <email@hidden>
- Date: Mon, 14 Jul 2014 16:32:25 -0700
On Jul 14, 2014, at 1:07 PM, Carl Hoefs <email@hidden> 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.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden