Replace body with do

This commit is contained in:
2018-01-31 12:05:06 +01:00
parent fd02c411e1
commit 048ddf21ff
22 changed files with 176 additions and 175 deletions

View File

@@ -56,7 +56,7 @@ struct Range(A)
assert(begin >= container.data);
assert(end <= container.data + container.length);
}
body
do
{
this.container = &container;
this.begin = begin;
@@ -87,7 +87,7 @@ struct Range(A)
{
assert(!empty);
}
body
do
{
return *this.begin;
}
@@ -97,7 +97,7 @@ struct Range(A)
{
assert(!empty);
}
body
do
{
return *(this.end - 1);
}
@@ -107,7 +107,7 @@ struct Range(A)
{
assert(!empty);
}
body
do
{
++this.begin;
}
@@ -117,7 +117,7 @@ struct Range(A)
{
assert(!empty);
}
body
do
{
--this.end;
}
@@ -127,7 +127,7 @@ struct Range(A)
{
assert(i < length);
}
body
do
{
return *(this.begin + i);
}
@@ -148,7 +148,7 @@ struct Range(A)
assert(i <= j);
assert(j <= length);
}
body
do
{
return typeof(return)(*this.container, this.begin + i, this.begin + j);
}
@@ -159,7 +159,7 @@ struct Range(A)
assert(i <= j);
assert(j <= length);
}
body
do
{
return typeof(return)(*this.container, this.begin + i, this.begin + j);
}
@@ -333,7 +333,7 @@ struct Array(T)
{
assert(allocator !is null);
}
body
do
{
allocator_ = allocator;
}
@@ -597,7 +597,7 @@ struct Array(T)
{
assert(!empty);
}
body
do
{
length = length - 1;
}
@@ -619,7 +619,7 @@ struct Array(T)
{
assert(removed <= howMany);
}
body
do
{
const toRemove = min(howMany, length);
@@ -662,7 +662,7 @@ struct Array(T)
assert(r.begin >= this.data);
assert(r.end <= this.data + length);
}
body
do
{
auto target = r.begin;
for (auto source = r.end; source != end; ++source, ++target)
@@ -821,7 +821,7 @@ struct Array(T)
assert(r.begin >= this.data);
assert(r.end <= this.data + length);
}
body
do
{
const oldLen = length;
const offset = r.end - this.data;
@@ -838,7 +838,7 @@ struct Array(T)
assert(r.begin >= this.data);
assert(r.end <= this.data + length);
}
body
do
{
return insertAfter!(T[])(r, el[]);
}
@@ -852,7 +852,7 @@ struct Array(T)
assert(r.begin >= this.data);
assert(r.end <= this.data + length);
}
body
do
{
const oldLen = length;
const offset = r.end - this.data;
@@ -881,7 +881,7 @@ struct Array(T)
assert(r.begin >= this.data);
assert(r.end <= this.data + length);
}
body
do
{
return insertAfter(Range(this, this.data, r.begin), el);
}
@@ -894,7 +894,7 @@ struct Array(T)
assert(r.begin >= this.data);
assert(r.end <= this.data + length);
}
body
do
{
return insertBefore!(T[])(r, el[]);
}
@@ -908,7 +908,7 @@ struct Array(T)
assert(r.begin >= this.data);
assert(r.end <= this.data + length);
}
body
do
{
const oldLen = length;
const offset = r.begin - this.data;
@@ -1080,7 +1080,7 @@ struct Array(T)
{
assert(length > pos);
}
body
do
{
return *(this.data + pos);
}
@@ -1185,7 +1185,7 @@ struct Array(T)
{
assert(!empty);
}
body
do
{
return *this.data;
}
@@ -1212,7 +1212,7 @@ struct Array(T)
{
assert(!empty);
}
body
do
{
return *(this.data + length - 1);
}
@@ -1245,7 +1245,7 @@ struct Array(T)
assert(i <= j);
assert(j <= length);
}
body
do
{
return typeof(return)(this, this.data + i, this.data + j);
}
@@ -1257,7 +1257,7 @@ struct Array(T)
assert(i <= j);
assert(j <= length);
}
body
do
{
return typeof(return)(this, this.data + i, this.data + j);
}
@@ -1328,7 +1328,7 @@ struct Array(T)
assert(i <= j);
assert(j <= length);
}
body
do
{
copy(value[], this.data[i .. j]);
return opSlice(i, j);
@@ -1342,7 +1342,7 @@ struct Array(T)
assert(i <= j);
assert(j <= length);
}
body
do
{
fill(this.data[i .. j], value);
return opSlice(i, j);
@@ -1356,7 +1356,7 @@ struct Array(T)
assert(j <= length);
assert(j - i == value.length);
}
body
do
{
copy(value, this.data[i .. j]);
return opSlice(i, j);

View File

@@ -27,7 +27,7 @@ version (unittest)
{
assert(start < end);
}
body
do
{
auto numberRead = end - start;
for (ubyte i; i < numberRead; ++i)
@@ -106,7 +106,7 @@ struct ReadBuffer(T = ubyte)
{
assert(allocator_ is null);
}
body
do
{
allocator_ = allocator;
}
@@ -349,7 +349,7 @@ struct WriteBuffer(T = ubyte)
assert(size > 0);
assert(allocator !is null);
}
body
do
{
blockSize = size;
ring = size - 1;
@@ -549,7 +549,7 @@ struct WriteBuffer(T = ubyte)
{
assert(length <= this.length);
}
body
do
{
auto afterRing = ring + 1;
auto oldStart = start;

View File

@@ -64,7 +64,7 @@ struct SRange(L)
{
assert(!empty);
}
body
do
{
return (*this.head).content;
}
@@ -74,7 +74,7 @@ struct SRange(L)
{
assert(!empty);
}
body
do
{
this.head = &(*this.head).next;
}
@@ -205,7 +205,7 @@ struct SList(T)
{
assert(allocator !is null);
}
body
do
{
this.allocator_ = allocator;
}
@@ -325,7 +325,7 @@ struct SList(T)
{
assert(!empty);
}
body
do
{
return this.head.content;
}
@@ -467,7 +467,7 @@ struct SList(T)
{
assert(checkRangeBelonging(r));
}
body
do
{
return moveEntry(*r.head, el);
}
@@ -490,7 +490,7 @@ struct SList(T)
{
assert(checkRangeBelonging(r));
}
body
do
{
size_t inserted;
foreach (e; el)
@@ -519,7 +519,7 @@ struct SList(T)
{
assert(checkRangeBelonging(r));
}
body
do
{
*r.head = allocator.make!Entry(el, *r.head);
return 1;
@@ -641,7 +641,7 @@ struct SList(T)
{
assert(!empty);
}
body
do
{
auto n = this.head.next;
@@ -680,7 +680,7 @@ struct SList(T)
{
assert(removed <= howMany);
}
body
do
{
size_t i;
for (; i < howMany && !empty; ++i)
@@ -716,7 +716,7 @@ struct SList(T)
{
assert(checkRangeBelonging(r));
}
body
do
{
auto outOfScopeList = typeof(this)(allocator);
outOfScopeList.head = *r.head;
@@ -963,7 +963,7 @@ struct DRange(L)
{
assert(!empty);
}
body
do
{
return (*this.head).content;
}
@@ -973,7 +973,7 @@ struct DRange(L)
{
assert(!empty);
}
body
do
{
return (*this.tail).content;
}
@@ -983,7 +983,7 @@ struct DRange(L)
{
assert(!empty);
}
body
do
{
this.head = &(*this.head).next;
}
@@ -993,7 +993,7 @@ struct DRange(L)
{
assert(!empty);
}
body
do
{
this.tail = &(*this.tail).prev;
}
@@ -1135,7 +1135,7 @@ struct DList(T)
{
assert(allocator !is null);
}
body
do
{
this.allocator_ = allocator;
}
@@ -1259,7 +1259,7 @@ struct DList(T)
{
assert(!empty);
}
body
do
{
return this.head.content;
}
@@ -1272,7 +1272,7 @@ struct DList(T)
{
assert(!empty);
}
body
do
{
return this.tail.content;
}
@@ -1311,17 +1311,17 @@ struct DList(T)
return 1;
}
// Creates a lsit of linked entries from a range.
// Returns count of the elements in the list.
private size_t makeList(R)(ref R el, out Entry* head, out Entry* tail) @trusted
out (retLength)
{
assert((retLength == 0 && head is null && tail is null)
|| (retLength > 0 && head !is null && tail !is null));
}
body
{
size_t retLength;
// Creates a lsit of linked entries from a range.
// Returns count of the elements in the list.
private size_t makeList(R)(ref R el, out Entry* head, out Entry* tail) @trusted
out (retLength)
{
assert((retLength == 0 && head is null && tail is null)
|| (retLength > 0 && head !is null && tail !is null));
}
do
{
size_t retLength;
if (!el.empty)
{
@@ -1336,8 +1336,8 @@ struct DList(T)
tail = tail.next;
++retLength;
}
return retLength;
}
return retLength;
}
/**
* Inserts a new element at the beginning.
@@ -1525,10 +1525,10 @@ struct DList(T)
{
this.head = begin;
}
else
{
else
{
this.tail.next = begin;
}
}
if (begin !is null)
{
this.tail = end;
@@ -1595,7 +1595,7 @@ struct DList(T)
{
assert(checkRangeBelonging(r));
}
body
do
{
return moveFront(*r.head, el);
}
@@ -1615,7 +1615,7 @@ struct DList(T)
{
assert(checkRangeBelonging(r));
}
body
do
{
auto temp = allocator.make!Entry(el, *r.head);
@@ -1653,7 +1653,7 @@ struct DList(T)
{
assert(checkRangeBelonging(r));
}
body
do
{
size_t inserted;
foreach (e; el)
@@ -1710,7 +1710,7 @@ struct DList(T)
{
assert(checkRangeBelonging(r));
}
body
do
{
return moveBack(*r.tail, el);
}
@@ -1741,7 +1741,7 @@ struct DList(T)
{
assert(checkRangeBelonging(r));
}
body
do
{
auto temp = allocator.make!Entry(el, null, *r.tail);
@@ -1779,7 +1779,7 @@ struct DList(T)
{
assert(checkRangeBelonging(r));
}
body
do
{
size_t inserted;
foreach (e; el)
@@ -1896,7 +1896,7 @@ struct DList(T)
{
assert(!empty);
}
body
do
{
auto n = this.head.next;
@@ -1932,7 +1932,7 @@ struct DList(T)
{
assert(!empty);
}
body
do
{
auto n = this.tail.prev;
@@ -1978,7 +1978,7 @@ struct DList(T)
{
assert(removed <= howMany);
}
body
do
{
size_t i;
for (; i < howMany && !empty; ++i)
@@ -2005,7 +2005,7 @@ struct DList(T)
{
assert(removed <= howMany);
}
body
do
{
size_t i;
for (; i < howMany && !empty; ++i)
@@ -2041,7 +2041,7 @@ struct DList(T)
{
assert(checkRangeBelonging(r));
}
body
do
{
// Save references to the elements before and after the range.
Entry* tailNext, headPrev;

View File

@@ -167,7 +167,7 @@ struct Queue(T)
{
assert(!empty);
}
body
do
{
auto n = first.next;
T ret = move(first.content);

View File

@@ -76,7 +76,7 @@ struct Range(E)
assert(this.dataRange.empty
|| this.dataRange.back.status == BucketStatus.used);
}
body
do
{
do
{
@@ -96,7 +96,7 @@ struct Range(E)
assert(this.dataRange.empty
|| this.dataRange.back.status == BucketStatus.used);
}
body
do
{
do
{
@@ -111,7 +111,7 @@ struct Range(E)
assert(!this.dataRange.empty);
assert(this.dataRange.front.status == BucketStatus.used);
}
body
do
{
return dataRange.front.content;
}
@@ -122,7 +122,7 @@ struct Range(E)
assert(!this.dataRange.empty);
assert(this.dataRange.back.status == BucketStatus.used);
}
body
do
{
return dataRange.back.content;
}
@@ -180,7 +180,7 @@ struct Set(T)
{
assert(allocator !is null);
}
body
do
{
this(allocator);
rehash(n);
@@ -192,7 +192,7 @@ struct Set(T)
{
assert(allocator !is null);
}
body
do
{
this.data = typeof(this.data)(allocator);
}
@@ -227,7 +227,7 @@ struct Set(T)
{
assert(allocator !is null);
}
body
do
{
this.data = typeof(this.data)(init.data, allocator);
}
@@ -239,7 +239,7 @@ struct Set(T)
{
assert(allocator !is null);
}
body
do
{
this.data = typeof(this.data)(move(init.data), allocator);
this.lengthIndex = init.lengthIndex;
@@ -285,7 +285,7 @@ struct Set(T)
{
assert(allocator !is null);
}
body
do
{
return cast(shared Allocator) this.data.allocator;
}
@@ -371,7 +371,7 @@ struct Set(T)
{
assert(buckets.length > 0);
}
body
do
{
return hash % buckets.length;
}

View File

@@ -91,7 +91,7 @@ if (is(Unqual!E == char))
assert(begin >= container.data);
assert(end <= container.data + container.length);
}
body
do
{
this.container = &container;
this.begin = begin;
@@ -122,7 +122,7 @@ if (is(Unqual!E == char))
{
assert(!empty);
}
body
do
{
return *this.begin;
}
@@ -132,7 +132,7 @@ if (is(Unqual!E == char))
{
assert(!empty);
}
body
do
{
return *(this.end - 1);
}
@@ -142,7 +142,7 @@ if (is(Unqual!E == char))
{
assert(!empty);
}
body
do
{
++this.begin;
}
@@ -152,7 +152,7 @@ if (is(Unqual!E == char))
{
assert(!empty);
}
body
do
{
--this.end;
}
@@ -162,7 +162,7 @@ if (is(Unqual!E == char))
{
assert(i < length);
}
body
do
{
return *(this.begin + i);
}
@@ -183,7 +183,7 @@ if (is(Unqual!E == char))
assert(i <= j);
assert(j <= length);
}
body
do
{
return typeof(return)(*this.container, this.begin + i, this.begin + j);
}
@@ -194,7 +194,7 @@ if (is(Unqual!E == char))
assert(i <= j);
assert(j <= length);
}
body
do
{
return typeof(return)(*this.container, this.begin + i, this.begin + j);
}
@@ -233,7 +233,7 @@ if (is(Unqual!E == char))
assert(begin >= container.data);
assert(end <= container.data + container.length);
}
body
do
{
this.container = &container;
this.begin = begin;
@@ -261,7 +261,7 @@ if (is(Unqual!E == char))
{
assert(chr < 0xd800 || chr > 0xdfff);
}
body
do
{
dchar chr;
ubyte units;
@@ -295,7 +295,7 @@ if (is(Unqual!E == char))
{
assert(!empty);
}
body
do
{
ubyte units;
if ((*begin & 0xf0) == 0xf0)
@@ -438,7 +438,7 @@ struct String
{
assert(allocator !is null);
}
body
do
{
this.allocator_ = allocator;
}
@@ -528,7 +528,7 @@ struct String
assert(capacity - length >= 4);
assert(src - 0x10000 < 0x100000);
}
body
do
{
auto dst = this.data + length;
@@ -546,7 +546,7 @@ struct String
{
assert(capacity - length >= 3);
}
body
do
{
auto dst = this.data + length;
if (chr < 0x80)
@@ -924,7 +924,7 @@ struct String
assert(j <= length);
assert(j - i == value.length);
}
body
do
{
auto target = opSlice(i, j);
copy(value, target);
@@ -941,7 +941,7 @@ struct String
assert(i <= j);
assert(j <= length);
}
body
do
{
copy(value[], this.data[i .. j]);
return opSlice(i, j);
@@ -957,7 +957,7 @@ struct String
assert(i <= j);
assert(j <= length);
}
body
do
{
for (auto p = this.data + i; p < this.data + j; ++p)
{
@@ -1038,7 +1038,7 @@ struct String
{
assert(length > pos);
}
body
do
{
return *(this.data + pos);
}
@@ -1188,7 +1188,7 @@ struct String
assert(i <= j);
assert(j <= length);
}
body
do
{
return typeof(return)(this, this.data + i, this.data + j);
}
@@ -1201,7 +1201,7 @@ struct String
assert(i <= j);
assert(j <= length);
}
body
do
{
return typeof(return)(this, this.data + i, this.data + j);
}
@@ -1509,7 +1509,7 @@ struct String
assert(r.begin >= this.data);
assert(r.end <= this.data + length);
}
body
do
{
auto end = this.data + this.length;
copy(ByCodeUnit!char(this, r.end, end), ByCodeUnit!char(this, r.begin, end));
@@ -1562,7 +1562,7 @@ struct String
assert(r.begin >= this.data);
assert(r.end <= this.data + length);
}
body
do
{
auto oldLen = this.data + length;
const inserted = insertBack(el);
@@ -1595,7 +1595,7 @@ struct String
assert(r.begin >= this.data);
assert(r.end <= this.data + length);
}
body
do
{
return insertAfter(R(this, this.data, r.begin), el);
}