> Peter
>
> Trim modifies the string in situ.
>
> Your trim code only does it once but parse is working 10,000 x.

Oops, I forgot about Rebol's side effects for a moment. However the  
trim code did it 10,000 times but didn't have so much to do 9999 of  
them.

This is a better test and still indicates trim is faster for this  
example:

speedtest: func [][
   st: now/precise
   loop 10000 [
     teststring: copy "I'm so not here"
     stripped: trim/with teststring "' "
   ]
   et: now/precise
   print ["10000 trim/with took:" difference et st]
   st: now/precise
   strip: charset [#" " #"'"]
   not-strip: complement strip
   loop 10000 [
     teststring: copy "I'm so not here"
     stripped: copy ""
     parse teststring [any [copy str some not-strip (insert tail  
stripped str)| some strip]]
   ]
   et: now/precise
   print ["10000 parse took:" difference et st]
]

 >> speedtest
10000 trim/with took: 0:00:00.013725
10000 parse took: 0:00:00.073276

Regards

Peter
-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to