[PATCH] D50197: [DebugInfo/DWARF] Try to make a loop more readable. NFC
Paul Robinson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 2 12:38:06 PDT 2018
probinson created this revision.
probinson added a reviewer: aprantl.
probinson added a project: debug-info.
Herald added subscribers: llvm-commits, JDevlieghere, hiraditya.
In a previous refactoring patch, Adrian didn't find this loop particularly readable, although admitted it was like that when I found it. :-)
I've tried renaming a variable and breaking up a condition, hopefully this will be clearer. I am very open to other ideas.
Repository:
rL LLVM
https://reviews.llvm.org/D50197
Files:
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
Index: llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -89,25 +89,28 @@
}
if (Lazy)
return;
+
// Find a reasonable insertion point within the vector. We skip over
// (a) units from a different section, (b) units from the same section
// but with lower offset-within-section. This keeps units in order
// within a section, although not necessarily within the object file,
// even if we do lazy parsing.
- auto I = this->begin();
+ auto InsertPt = this->begin();
uint32_t Offset = 0;
while (Data.isValidOffset(Offset)) {
- if (I != this->end() &&
- (&(*I)->getInfoSection() != &Section || (*I)->getOffset() == Offset)) {
- ++I;
- continue;
+ if (InsertPt != this->end()) {
+ if (&(*InsertPt)->getInfoSection() != &Section ||
+ (*InsertPt)->getOffset() == Offset) {
+ ++InsertPt;
+ continue;
+ }
}
auto U = Parser(Offset, SectionKind, &Section);
// If parsing failed, we're done with this section.
if (!U)
break;
Offset = U->getNextUnitOffset();
- I = std::next(this->insert(I, std::move(U)));
+ InsertPt = std::next(this->insert(InsertPt, std::move(U)));
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50197.158817.patch
Type: text/x-patch
Size: 1341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180802/392ceed7/attachment.bin>
More information about the llvm-commits
mailing list