Le 29 mai 2013 à 00:46, Graham Cox <graham....@bigpond.com> a écrit :

> 
> On 28/05/2013, at 3:46 PM, Oleg Krupnov <oleg.krup...@gmail.com> wrote:
> 
>> I'd like to have a dictionary using C strings as keys (because I
>> already have const char* strings and would like to spare on creating
>> NSString wrappers)
> 
> 
> For the sake of avoiding something you *assume* to be slow, or inefficient, 
> you've taken the discussion in a direction that is vastly more complicated.
> 
> Why not just create NSString wrappers? By using the 
> -initWithBytesNoCopy:length:encoding:freeWhenDone: method you can avoid it 
> copying the actual C string characters, it literally just becomes a thin 
> wrapper.
> 
> K.I.S.S.! If you can prove this approach is a problem by actual profiling, 
> then OK, then you can talk about a more complex solution.

It may be a thin wrapper. Unlike with NSData that actually wraps the passed 
buffer, NSString does not make any guarantee about what it does.
My experience is that most of the times, NSString with actually copy the bytes 
and create its own internal representation.

That said, even if NSString creates an internal representation, I agree that 
trying a more complex approach without profiling data is pointless.

-- Jean-Daniel





_______________________________________________

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