• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [NSMutableData resetDataRangeTo:(NSRange)range];
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSMutableData resetDataRangeTo:(NSRange)range];


  • Subject: Re: [NSMutableData resetDataRangeTo:(NSRange)range];
  • From: Mike Abdullah <email@hidden>
  • Date: Tue, 15 Jul 2014 09:45:12 +0100

On 15 Jul 2014, at 00:32, Jens Alfke <email@hidden> wrote:

>
> 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.

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 (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


  • Follow-Ups:
    • Re: [NSMutableData resetDataRangeTo:(NSRange)range];
      • From: Carl Hoefs <email@hidden>
References: 
 >[NSMutableData resetDataRangeTo:(NSRange)range]; (From: Carl Hoefs <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Matt Gough <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Carl Hoefs <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Mike Abdullah <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Carl Hoefs <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Ben Kennedy <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Carl Hoefs <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Jens Alfke <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Carl Hoefs <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Jens Alfke <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Carl Hoefs <email@hidden>)
 >Re: [NSMutableData resetDataRangeTo:(NSRange)range]; (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Unwanted enclosingScrollView
  • Next by Date: Re: can I safely ignore <Error>: CGAffineTransformInvert: singular matrix?
  • Previous by thread: Re: [NSMutableData resetDataRangeTo:(NSRange)range];
  • Next by thread: Re: [NSMutableData resetDataRangeTo:(NSRange)range];
  • Index(es):
    • Date
    • Thread