mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 22:50:38 +03:00
use constructors instead of move
This commit is contained in:
parent
5c10e1faf5
commit
b8610beec3
3 changed files with 89 additions and 66 deletions
|
@ -1641,6 +1641,12 @@ if (isInputRange!R)
|
|||
if (!_input.empty) popFront();
|
||||
}
|
||||
|
||||
private this(R input, Tuple!(MutableE, uint) current)
|
||||
{
|
||||
_input = input;
|
||||
_current = current;
|
||||
}
|
||||
|
||||
///
|
||||
void popFront()
|
||||
{
|
||||
|
@ -1686,12 +1692,7 @@ if (isInputRange!R)
|
|||
///
|
||||
@property typeof(this) save()
|
||||
{
|
||||
import std.algorithm.mutation : move;
|
||||
typeof(this) ret = this;
|
||||
auto saved = this._input.save;
|
||||
move(saved, ret._input);
|
||||
ret._current = this._current;
|
||||
return ret;
|
||||
return Group(_input.save, _current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5161,6 +5162,24 @@ private struct SplitterResult(alias isTerminator, Range)
|
|||
_end = size_t.max;
|
||||
}
|
||||
|
||||
static if (fullSlicing)
|
||||
{
|
||||
private this(Range input, size_t end)
|
||||
{
|
||||
_input = input;
|
||||
_end = end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
private this(Range input, size_t end, Range next)
|
||||
{
|
||||
_input = input;
|
||||
_end = end;
|
||||
_next = next;
|
||||
}
|
||||
}
|
||||
|
||||
static if (isInfinite!Range)
|
||||
{
|
||||
enum bool empty = false; // Propagate infiniteness.
|
||||
|
@ -5225,16 +5244,10 @@ private struct SplitterResult(alias isTerminator, Range)
|
|||
|
||||
@property typeof(this) save()
|
||||
{
|
||||
import std.algorithm.mutation : move;
|
||||
auto ret = this;
|
||||
auto savedInput = _input.save;
|
||||
move(savedInput, ret._input);
|
||||
static if (!fullSlicing)
|
||||
{
|
||||
auto savedNext = _next.save;
|
||||
move(savedNext, ret._next);
|
||||
}
|
||||
return ret;
|
||||
static if (fullSlicing)
|
||||
return SplitterResult(_input.save, _end);
|
||||
else
|
||||
return SplitterResult(_input.save, _end, _next.save);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4921,6 +4921,7 @@ if (isInputRange!Range)
|
|||
private bool _done;
|
||||
|
||||
static if (!is(Sentinel == void))
|
||||
{
|
||||
///
|
||||
this(Range input, Sentinel sentinel,
|
||||
OpenRight openRight = Yes.openRight)
|
||||
|
@ -4930,7 +4931,17 @@ if (isInputRange!Range)
|
|||
_openRight = openRight;
|
||||
_done = _input.empty || openRight && predSatisfied();
|
||||
}
|
||||
private this(Range input, Sentinel sentinel, OpenRight openRight,
|
||||
bool done)
|
||||
{
|
||||
_input = input;
|
||||
_sentinel = sentinel;
|
||||
_openRight = openRight;
|
||||
_done = done;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
///
|
||||
this(Range input, OpenRight openRight = Yes.openRight)
|
||||
{
|
||||
|
@ -4938,6 +4949,13 @@ if (isInputRange!Range)
|
|||
_openRight = openRight;
|
||||
_done = _input.empty || openRight && predSatisfied();
|
||||
}
|
||||
private this(Range input, OpenRight openRight, bool done)
|
||||
{
|
||||
_input = input;
|
||||
_openRight = openRight;
|
||||
_done = done;
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
@property bool empty()
|
||||
|
@ -4979,31 +4997,14 @@ if (isInputRange!Range)
|
|||
|
||||
static if (isForwardRange!Range)
|
||||
{
|
||||
static if (!is(Sentinel == void))
|
||||
///
|
||||
@property Until save()
|
||||
{
|
||||
import std.algorithm.mutation : move;
|
||||
Until result = this;
|
||||
auto saved = _input.save;
|
||||
move(saved, result._input);
|
||||
result._sentinel = _sentinel;
|
||||
result._openRight = _openRight;
|
||||
result._done = _done;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
///
|
||||
@property Until save()
|
||||
{
|
||||
import std.algorithm.mutation : move;
|
||||
Until result = this;
|
||||
auto saved = _input.save;
|
||||
move(saved, result._input);
|
||||
result._openRight = _openRight;
|
||||
result._done = _done;
|
||||
return result;
|
||||
}
|
||||
///
|
||||
@property Until save()
|
||||
{
|
||||
static if (is(Sentinel == void))
|
||||
return Until(_input.save, _openRight, _done);
|
||||
else
|
||||
return Until(_input.save, _sentinel, _openRight, _done);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue