D-Programming-Language/phobos — pull request #701 by monarchdodra (2012-07-18 14:53:27+00:00)
Title: Various save/validity/performance related corrections

Particularly in "fill", "equal" "minPos" "minCount" and "adjacentFind".

Particularly:
*minPos, minCount: Banned infinite range, as it really makes no sense to search for infinity.

*adjacentFind, minPos, fill: Correct usage of save.

*minCount: removed a "reference based implementation" that did not work with all input ranges. Used a copy of the front element in case of inputRange, and used a save in case of forwardRange.

*fill(value): Lowered requirement from (assignable) forwardRange to (assignable) outputRange

*fill(range): Reworked the implementation to:
**Exploit boundless infinite range
**Defer copying to "copy" in case of ranges that support with length and slice.

*map: Changed the default input type of "opIndex" and "opSlice":
**Use the same type as length when length is available.
**Use size_t by default.
**Always make sure the code compiles, which is not always the case.

*equal: Added extra cases for when the ranges have length. This allows to:
**Avoids checking both ranges are empty, when iterating.
**potentially skip all comparisons, making the operation O(1)*

The only thing I'm not so sure about is equal just returning false if both ranges have a different length. Actually checking each element is stupid, but the doc specifies "applies op until the result is different"...