which is faster for searching?
ambassador at fourthworld.com
Wed Jun 18 11:41:31 EDT 2014
"Filter" is a wonderful command that's almost always much faster than
"repeat for each...", provided you're looking for data across a
collection comprised of single-column rows.
Once you get to multiple columns and you're searching just one of them,
"repeat for each..." scales linearly quite nicely but the performance of
"filter" degrades almost geometrically.
This is understandable given what regex is designed for: any generalized
solution optimized for the programmer's convenience will be doing a lot
of work under the hood.
Many aspects of LiveCode are seductive that way, leading us to believe
that the less typing we're doing the more efficient our code will be.
While often true there are many exceptions, and the dynamic compiler can
be surprisingly efficient at times.
There are even cases where "repeat for each" on simple chunks is faster
than array traversal, if the array is nested deeply enough.
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
Follow me on Twitter: http://twitter.com/FourthWorldSys
More information about the Use-livecode