On Mar 3, 2012, at 3:03 PM, Eli Bach2 wrote:

> 
> On Mar 3, 2012, at 12:15 PM, Jens Alfke wrote:
> 
>> I filed a bug report* saying that this substring optimization shouldn’t be 
>> used if the source string uses an external buffer, just as it shouldn’t if 
>> the source string is mutable. They fixed it, but some people there argue 
>> that their original implementation was correct (even if not compatible with 
>> Apple’s.) I’m curious, so I’m asking here to see if anyone knows for sure 
>> what’s intended.
> 
> Well, you can argue that the substring can't just reference the original 
> string and bump it's retaincount to make sure the underlying data stays 
> around because the original string doesn't own the data buffer.  For it to be 
> 'correct', there would at least need to be some mechanism to notify the data 
> buffer owner that another object was using it.

I’m not sure I’d want that either, though. If the original string was a 
200-page dissertation and you took a one-word substring from it, it doesn’t 
seem reasonable to keep the whole 200-page dissertation all in RAM just to keep 
the one-word substring around.

Charles

_______________________________________________

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