Re: Which is faster ?
- Posted by DerekParnell (admin) Feb 17, 2009
- 958 views
mattlewis said...
DerekParnell said...
Just a bit more clarification, find() is faster for long sequences. If the sequence is, say less than 10-15 items, then a loop can be faster.
Do you have any benchmarks that demonstrate this?
No. Actually I mis-remembered. What I was thinking about was the difference between find() and map() - there is a point at which map() becomes faster than find(). But you are correct, find() is always faster than looping if you have an unordered sequence to scan through.