On 5/27/16 8:28 AM, Chris wrote:
I've played around with some algorithms and kept them as simple as possible, but I've found that a linear brute force for-loop always beats them (it's the extra decision(s), I suppose). It looks nice in theory, but in hardware reality a stupid loop is more efficient.
This is surprising. It should be easy to construct examples where brute force search performs arbitrarily poor, e.g. searching for "aaaaaaa...aab" in a long string with only "a"s.
NB: I've found that `foreach` is usually faster than a manual `for`-loop.
That's surprising too. I'd be interested to look at a disassembly if you have one.
I used qznc's benchmarking, and it's clear that the current implementation of std.algorithm.find is quite a poor performer. We do have to work on that. Library functions should be fast, no matter what. If someone uses `find`, they wanna be sure it's optimized for speed.
That's definitely the way to go. Thanks for looking into it! Andrei