Re: Fastest way to replace characters in string

2013-08-23 Thread Thomas Wetmore
On Aug 23, 2013, at 9:40 AM, Alex Zavatone wrote: > > Why isn't it a good idea to have everything set up before you need it? > > In my reasoning, If there is downtime when items can be set up of prefetched > before they are needed, then they are ready for use when needed. > > If you don't d

Re: Fastest way to replace characters in string

2013-08-23 Thread Alex Zavatone
On Aug 22, 2013, at 2:05 PM, Thomas Wetmore wrote: > Steve, > > Sorry, again I was unclear. Here is what I am trying to say: > > Pre-allocation means to allocate space before you need it, which would be at > init time. > > But there is no need to pre-allocate -- the first allocation can be po

Re: Fastest way to replace characters in string

2013-08-22 Thread Jens Alfke
On Aug 22, 2013, at 11:05 AM, Thomas Wetmore wrote: > Pre-allocation means to allocate space before you need it, which would be at > init time. > But there is no need to pre-allocate -- the first allocation can be postponed > until the first item is put in the container or characters in the st

Re: Fastest way to replace characters in string

2013-08-22 Thread Marcel Weiher
On Aug 22, 2013, at 19:43 , Steve Mills wrote: > On Aug 22, 2013, at 12:31:55, Thomas Wetmore > wrote: > >> Pre-allocation doesn't really matter as long as the re-allocations, whenever >> they occur, respect the capacity argument. > > Sure they do. If you don't preallocate, but instead keep

Re: Fastest way to replace characters in string

2013-08-22 Thread Keary Suska
On Aug 22, 2013, at 12:05 PM, Thomas Wetmore wrote: > Steve, > > Sorry, again I was unclear. Here is what I am trying to say: > > Pre-allocation means to allocate space before you need it, which would be at > init time. > > But there is no need to pre-allocate -- the first allocation can be po

Re: Fastest way to replace characters in string

2013-08-22 Thread Thomas Wetmore
Steve, Sorry, again I was unclear. Here is what I am trying to say: Pre-allocation means to allocate space before you need it, which would be at init time. But there is no need to pre-allocate -- the first allocation can be postponed until the first item is put in the container or characters i

Re: Fastest way to replace characters in string

2013-08-22 Thread Thomas Wetmore
Steve, I apologize that what I wrote wasn't clear. Pre-allocation simply means to allocate space BEFORE you need it. And all that means is that the FIRST allocation doesn't occur at init time, but WAITS until you actually put something in the string or container. From that point of view pre-all

Re: Fastest way to replace characters in string

2013-08-22 Thread Steve Mills
On Aug 22, 2013, at 12:31:55, Thomas Wetmore wrote: > Pre-allocation doesn't really matter as long as the re-allocations, whenever > they occur, respect the capacity argument. Sure they do. If you don't preallocate, but instead keep appending, and the pointer needs to grow with every append,

Re: Fastest way to replace characters in string

2013-08-22 Thread Thomas Wetmore
Pre-allocation doesn't really matter as long as the re-allocations, whenever they occur, respect the capacity argument. Tom Wetmore On Aug 22, 2013, at 1:22 PM, Keary Suska wrote: > On Aug 22, 2013, at 9:06 AM, Jens Alfke wrote: > >> create the empty output mutable string with sufficient capa

Re: Fastest way to replace characters in string

2013-08-22 Thread Keary Suska
On Aug 22, 2013, at 9:06 AM, Jens Alfke wrote: > create the empty output mutable string with sufficient capacity (i.e. maybe > 2x the input string length) On an entirely different note, does the various initWithCapacity methods of mutable classes actually do any pre-allocation? Last I understo

Re: Fastest way to replace characters in string

2013-08-22 Thread Jens Alfke
On Aug 22, 2013, at 3:05 AM, Diederik Meijer | Ten Horses wrote: > What actually speeds things up significantly is to revert back to NSString > and use NSRegularExpression. > I now needs seven seconds on iPad3 to handle >600 replacement actions. This > is, in itself a VERY long time Indeed.;

Re: Fastest way to replace characters in string

2013-08-22 Thread Marcel Weiher
Hi Diederik, On Aug 22, 2013, at 1:44 , Diederik Meijer | Ten Horses wrote: > The content is quite large, about 1MB, it is the full text of a law. Hmm…that isn’t really that large, we have GHz computing buzz-saws! > The web service returns the list lightning fast, but in order to get the >

Re: Fastest way to replace characters in string

2013-08-22 Thread Diederik Meijer | Ten Horses
Thanks Esteban and Wim, Indeed, using javascript or jQuery can also be an option. What actually speeds things up significantly is to revert back to NSString and use NSRegularExpression. I now needs seven seconds on iPad3 to handle >600 replacement actions. This is, in itself a VERY long time,

Re: Fastest way to replace characters in string

2013-08-21 Thread Wim Lewis
On 21 Aug 2013, at 4:44 PM, Diederik Meijer | Ten Horses wrote: > The web service returns the list lightning fast, but in order to get the > count number added to each of the >300 articles html header, I am > looping through the list and call NSString's > stringByReplacingOccurancesOfString:wi

Re: Fastest way to replace characters in string

2013-08-21 Thread Esteban Torres
Don't know if this helps you Diederik but from what I've read the parser developed by Oliver Drobnik would be a good place to start on implementing your own or even using his DTHTMLParser: http://www.cocoanetics.com/2013/08/dtfoundation-1-5-2/ Regards, -- Esteban Torres (+506)8813-0934 Skype:

Fastest way to replace characters in string

2013-08-21 Thread Diederik Meijer | Ten Horses
Dear list, I have an iOS app that loads a local html file into a UIWebView. The content is quite large, about 1MB, it is the full text of a law. By tapping a button, users can reveal the number of published court rulings for each of the law's articles. As this data changes frequently, a list t