On Thu, Feb 5, 2009 at 4:16 PM, Shawn Erickson <[email protected]> wrote:
> On Thu, Feb 5, 2009 at 3:39 PM, harry greenmonster
> <[email protected]> wrote:
>
>> 'inputString' is a 5mb text file,
>
> Since inputString is large you really should avoid causing it to be
> copied over and over again which -[NSString
> stringByReplacingCharactersInRange:withString:] is doing. You should
> instead use a mutable string and -[NSMutableString
> replaceCharactersInRange:withString:].
>
> NSMutableString* tmpString = [[inputString mutableCopy] autorelease];
> while([tmpString isMatchedByRegex:regexString]) {
>       range = [tmpString rangeOfRegex:regexString];
>       [tmpString replaceCharactersInRange:range withString:@""];
> }

...better yet use -[NSMutableString deleteCharactersInRange:] given
you are replacing with an empty string.

-Shawn
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to