D-Programming-Language/phobos — pull request #1035 by monarchdodra (2012-12-26 15:43:05+00:00)
Title: Maintenance in [starts|ends]With

1. Started by changing `Ranges...` => `Needles...`, because not all `withOneOfThese` are actually ranges.

2. cleaned up `endsWith` unittest.

3. Added a teensy bit of unicode unittest for both.

4. Optimized flow in `startsWith` for ranges with "comparable length" (that includes narrow strings of matching types), as well as unlocked a code path for RA ranges (as opposed to only arrays).

5. Finally, added a shortcut in `startsWith(Range, Needles...)` on the first "element match": Once we've matched an element, there is no need to keep searching.

That's about it, each of these sentences have their associated commit.

--------
Note that there is still a LOT of room for improvement in `startsWith(Range, Needles...)`: It currently checks empty twice for each range on every iteration. Further more, on every mis-match, it restarts the current iteration from the first needle (checking for empty... once again). These would require more involved fixes, so I stopped here for now. 5. already mitigates some of this problem.