Merge pull request #879 from monarchdodra/walkSave

saving before calling walkLength
This commit is contained in:
Andrei Alexandrescu 2012-10-25 06:25:56 -07:00
commit 6e9cf770d8

View file

@ -3179,7 +3179,7 @@ if (isRandomAccessRange!R1 && isBidirectionalRange!R2
&& is(typeof(binaryFun!pred(haystack.front, needle.front)) : bool)) && is(typeof(binaryFun!pred(haystack.front, needle.front)) : bool))
{ {
if (needle.empty) return haystack; if (needle.empty) return haystack;
const needleLength = walkLength(needle); const needleLength = walkLength(needle.save);
if (needleLength > haystack.length) if (needleLength > haystack.length)
{ {
// @@@BUG@@@ // @@@BUG@@@
@ -5743,7 +5743,7 @@ struct Levenshtein(Range, alias equals, CostType = size_t)
CostType distance(Range s, Range t) CostType distance(Range s, Range t)
{ {
auto slen = walkLength(s), tlen = walkLength(t); auto slen = walkLength(s.save), tlen = walkLength(t.save);
AllocMatrix(slen + 1, tlen + 1); AllocMatrix(slen + 1, tlen + 1);
foreach (i; 1 .. rows) foreach (i; 1 .. rows)
{ {