Re: faster deparse() for string library strtok.e
- Posted by petelomax at blueyonder.co.uk Apr 02, 2002
- 462 views
On Tue, 2 Apr 2002 12:47:17 -0500 , Matthew Lewis <matthewwalkerlewis at YAHOO.COM> wrote: Oh Matt, the perils & embarrassment of posting untested code... Your routine when passed {"I","did","not","test","this"} returns "Ididnottestthis" rather than "I did not test this" Anyway , works fine with: > ix += len > end for > return s[1..ix-1] replaced by: ix += len+1 end for return s[1..ix-2] I suspect there's a nasty slice error waiting there though [0..-1]; it still needs an if len/else return "" clause, I think. Also, rather than pick slen=256 I would suggest guessing the average length of a word & pre-allocating that; extending by length of this word+av.length*remaining words left if necessary. Pete