Re: faster deparse() for string library strtok.e

new topic     » goto parent     » topic index » view thread      » older message » newer message

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 blink , 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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu