• 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: Simple memory problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple memory problem


  • Subject: Re: Simple memory problem
  • From: Shawn Erickson <email@hidden>
  • Date: Thu, 5 Feb 2009 16:16:15 -0800

On Thu, Feb 5, 2009 at 3:39 PM, harry greenmonster
<email@hidden> 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:@""];
}

-Shawn
_______________________________________________

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: Simple memory problem
      • From: Graham Cox <email@hidden>
    • Re: Simple memory problem
      • From: Shawn Erickson <email@hidden>
    • Re: Simple memory problem
      • From: harry greenmonster <email@hidden>
References: 
 >Simple memory problem (From: harry greenmonster <email@hidden>)

  • Prev by Date: Re: Needed : set class for Cocoa
  • Next by Date: Re: Simple memory problem
  • Previous by thread: Re: Simple memory problem
  • Next by thread: Re: Simple memory problem
  • Index(es):
    • Date
    • Thread