Skip to content

Commit

Permalink
Quick splitter countUntil fix
Browse files Browse the repository at this point in the history
This is more of a band-aid..., splitter needs some deep fixing anyways...
  • Loading branch information
monarchdodra committed Nov 20, 2012
1 parent a98a93f commit 0a3b7be
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions std/algorithm.d
Expand Up @@ -1924,7 +1924,7 @@ assert(equal(splitter(a, 0), [ [], [1] ]));
*/
auto splitter(Range, Separator)(Range r, Separator s)
if (is(typeof(ElementType!Range.init == Separator.init))
&& (hasSlicing!Range || isNarrowString!Range))
&& ((hasSlicing!Range && hasLength!Range) || isNarrowString!Range))
{
static struct Result
{
Expand All @@ -1941,8 +1941,8 @@ if (is(typeof(ElementType!Range.init == Separator.init))
{
static IndexType lastIndexOf(Range haystack, Separator needle)
{
immutable index = countUntil(retro(haystack), needle);
return (index == -1) ? -1 : haystack.length - 1 - index;
auto r = haystack.retro().find(needle);
return r.retro().length - 1;
}
}

Expand Down Expand Up @@ -1970,8 +1970,8 @@ if (is(typeof(ElementType!Range.init == Separator.init))
assert(!empty);
if (_frontLength == _unComputed)
{
_frontLength = countUntil(_input, _separator);
if (_frontLength == -1) _frontLength = _input.length;
auto r = _input.find(_separator);
_frontLength = _input.length - r.length;
}
return _input[0 .. _frontLength];
}
Expand Down

0 comments on commit 0a3b7be

Please sign in to comment.