Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Fast way to strip characters

From: petr:krenzelok:seznam:cz at: 7-Oct-2009 10:27

Hi list, far from being a parse guru, but here's a bit more hopefully optimised and easier version :-) 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 [#" " #"'"] loop 10000 [ teststring: copy "I'm so not here" parse/all teststring [any [here: strip (remove here) | skip]] ] et: now/precise print ["10000 parse took:" difference et st] ] ->> speedtest 10000 trim/with took: 0:00:00.018 10000 parse took: 0:00:00.046 PS: without the /all refinement, spaces were not even considered .... however - by consecutively running speedtest, result times jump here and there ... Cheers, -pekr-