Re: Initializing a NSMutableString an odd way

2013-08-03 Thread Andreas Grosam
On 31.07.2013, at 22:01, Greg Parker gpar...@apple.com wrote: On Jul 31, 2013, at 12:28 PM, Vincent Habchi vi...@macports.org wrote: David Duncan wrote: Why would there be? Your just asking for a mutable copy of an empty string. It should be equivalent to [[NSMutableString alloc]

Initializing a NSMutableString an odd way

2013-07-31 Thread Vincent Habchi
Folks, I apologize if this question looks stupid or contrived. Here it is: is it permissible to use [@“” mutableCopy] to initialize (or reset) a NSMutableString instead of the more classical [[NSMutableString alloc] init]? Thanks a lot! Vincent

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Mike Abdullah
On 31 Jul 2013, at 19:09, Vincent Habchi vi...@macports.org wrote: Folks, I apologize if this question looks stupid or contrived. Here it is: is it permissible to use [@“” mutableCopy] to initialize (or reset) a NSMutableString instead of the more classical [[NSMutableString alloc]

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Vincent Habchi
Le 31 juil. 2013 à 20:15, Mike Abdullah mabdul...@karelia.com a écrit : I apologize if this question looks stupid or contrived. Here it is: is it permissible to use [@“” mutableCopy] to initialize (or reset) a NSMutableString instead of the more classical [[NSMutableString alloc] init]?

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread David Duncan
On Jul 31, 2013, at 11:25 AM, Vincent Habchi vi...@macports.org wrote: Le 31 juil. 2013 à 20:15, Mike Abdullah mabdul...@karelia.com a écrit : I apologize if this question looks stupid or contrived. Here it is: is it permissible to use [@“” mutableCopy] to initialize (or reset) a

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Fritz Anderson
On 31 Jul 2013, at 1:28 PM, David Duncan david.dun...@apple.com wrote: On Jul 31, 2013, at 11:25 AM, Vincent Habchi vi...@macports.org wrote: Le 31 juil. 2013 à 20:15, Mike Abdullah mabdul...@karelia.com a écrit : I apologize if this question looks stupid or contrived. Here it is: is it

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Ken Thomases
On Jul 31, 2013, at 1:45 PM, Fritz Anderson wrote: On 31 Jul 2013, at 1:28 PM, David Duncan david.dun...@apple.com wrote: On Jul 31, 2013, at 11:25 AM, Vincent Habchi vi...@macports.org wrote: Le 31 juil. 2013 à 20:15, Mike Abdullah mabdul...@karelia.com a écrit : I apologize if this

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Vincent Habchi
Thanks to all for answering, Why would there be? Your just asking for a mutable copy of an empty string. It should be equivalent to [[NSMutableString alloc] initWithString:@« »] But much slower I expect, since it creates a NSString, takes a mutable copy, then implicitly releases the

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Sandor Szatmari
I think there are some overlooked subtleties as @ is a string literal. Retain and release are pretty much meaningless to it. Sandor Szatmari On Jul 31, 2013, at 15:28, Vincent Habchi vi...@macports.org wrote: Thanks to all for answering, Why would there be? Your just asking for a mutable

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Fritz Anderson
On 31 Jul 2013, at 2:28 PM, Vincent Habchi vi...@macports.org wrote: Thanks to all for answering, Why would there be? Your just asking for a mutable copy of an empty string. It should be equivalent to [[NSMutableString alloc] initWithString:@« »] But much slower I expect, since it

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Greg Parker
On Jul 31, 2013, at 12:28 PM, Vincent Habchi vi...@macports.org wrote: David Duncan wrote: Why would there be? Your just asking for a mutable copy of an empty string. It should be equivalent to [[NSMutableString alloc] initWithString:@« »] But much slower I expect, since it creates a

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Gary L. Wade
On 7/31/2013 1:01 PM, Greg Parker gpar...@apple.com wrote: Simple alloc/init is the fastest: 100 [[[NSMutableString alloc] init] release] 102 [[NSMutableString new] release] 109 [NSMutableString string] // ARC enabled 117 [[@ mutableCopy] release] 119 @autoreleasepool { [NSMutableString

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Vincent Habchi
Greg, thanks for diverting some of your time testing this. As someone already commented, the results are somehow consistent with “common sense”, whatever that means (cf. below). ARC and non-ARC scores are the same within measurement noise, except for [NSMutableString string] where ARC can

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Greg Parker
On Jul 31, 2013, at 1:32 PM, Vincent Habchi vi...@macports.org wrote: Greg Parker wrote: ARC and non-ARC scores are the same within measurement noise, except for [NSMutableString string] where ARC can optimize the autoreleased return value so the test doesn't need to spin the autorelease

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Sandor Szatmari
Why not [aMutableString setString:@];? Sandor Szatmari On Jul 31, 2013, at 16:32, Vincent Habchi vi...@macports.org wrote: Greg, thanks for diverting some of your time testing this. As someone already commented, the results are somehow consistent with “common sense”, whatever that means

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Vincent Habchi
Le 31 juil. 2013 à 22:38, Greg Parker gpar...@apple.com a écrit : Not necessarily. If you have long string and you want to clear it and re-fill it with another long string, then it may be faster to use -deleteCharactersInRange: in order to avoid memory re-allocation overhead. But that

Re: Initializing a NSMutableString an odd way

2013-07-31 Thread Alex Zavatone
On Jul 31, 2013, at 4:01 PM, Greg Parker wrote: On Jul 31, 2013, at 12:28 PM, Vincent Habchi vi...@macports.org wrote: David Duncan wrote: Why would there be? Your just asking for a mutable copy of an empty string. It should be equivalent to [[NSMutableString alloc] initWithString:@« »]