Still the principle that merlyn stated is correct, and is a common performance mistake in parsing. Try it with a 1 MB string. If substr still wins then I guarantee you that someone implemented a buffering strategy with strings and substr where doing a destructive substr at the beginning of a string just moves indexes around and does not recopy.
Perl plays a lot of games like that, for instance that is why push, pop and friends are fast. I am just a little surprised to see it played on strings...
In reply to Re (tilly) 8: how do I line-wrap while copying to stdout?
by tilly
in thread how do I line-wrap while copying to stdout?
by ams
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |