mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
[CodeView] Simplify StreamArray operator++
llvm-svn: 271419
This commit is contained in:
parent
818581cd0c
commit
0d36b051c9
@ -77,10 +77,7 @@ public:
|
||||
auto EC = Extract(IterRef, ThisLen, ThisValue);
|
||||
if (EC) {
|
||||
consumeError(std::move(EC));
|
||||
this->Array = nullptr;
|
||||
HasError = true;
|
||||
if (HadError)
|
||||
*HadError = true;
|
||||
markError();
|
||||
}
|
||||
}
|
||||
VarStreamArrayIterator() : Array(nullptr), IterRef(), HasError(false) {}
|
||||
@ -109,24 +106,24 @@ public:
|
||||
}
|
||||
|
||||
IterType &operator++() {
|
||||
if (!Array || IterRef.getLength() == 0 || ThisLen == 0 || HasError)
|
||||
return *this;
|
||||
// We are done with the current record, discard it so that we are
|
||||
// positioned at the next record.
|
||||
IterRef = IterRef.drop_front(ThisLen);
|
||||
if (IterRef.getLength() == 0)
|
||||
ThisLen = 0;
|
||||
else {
|
||||
if (IterRef.getLength() == 0) {
|
||||
// There is nothing after the current record, we must make this an end
|
||||
// iterator.
|
||||
moveToEnd();
|
||||
} else {
|
||||
// There is some data after the current record.
|
||||
auto EC = Extract(IterRef, ThisLen, ThisValue);
|
||||
if (EC) {
|
||||
consumeError(std::move(EC));
|
||||
HasError = true;
|
||||
if (HadError)
|
||||
*HadError = true;
|
||||
markError();
|
||||
} else if (ThisLen == 0) {
|
||||
// An empty record? Make this an end iterator.
|
||||
moveToEnd();
|
||||
}
|
||||
}
|
||||
if (ThisLen == 0 || HasError) {
|
||||
Array = nullptr;
|
||||
ThisLen = 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -137,6 +134,17 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void moveToEnd() {
|
||||
Array = nullptr;
|
||||
ThisLen = 0;
|
||||
}
|
||||
void markError() {
|
||||
moveToEnd();
|
||||
HasError = true;
|
||||
if (HadError != nullptr)
|
||||
*HadError = true;
|
||||
}
|
||||
|
||||
const ArrayType *Array;
|
||||
uint32_t ThisLen;
|
||||
ValueType ThisValue;
|
||||
|
Loading…
Reference in New Issue
Block a user