in reply to More benchmarks and stuff
in thread is split optimized?
No, it has to do with what split and regex produce, not with what they get (behind the scenes, everything is a reference anyway). The regex only has to create a short new string, while the split (even if there's a split into 2 fields) has to create a large new string. And that's taking time.
So, if you have a gigantic string, and you only want the first, short field, a regex is the way to go. But usually you encounter short strings, and that's when split works better, despite itself using a regex. (But a much simpler regex, and it even might be that the case of " " is optimized itself too).
-- Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
The conclusion of: More benchmarks and stuff
by gryng (Hermit) on Jul 15, 2000 at 02:25 UTC |