Skip to content

Commit

Permalink
[AppleAccelTable][NFC] Improve code readability
Browse files Browse the repository at this point in the history
This commit does a few minor NFC cleanups:

* A variable was called "Atom", probably trying to claim it was an AtomType.
This was incorrect, it is actually a FormValue.

* LLVM provides a `zip_equal` to express the intent of asserting ranges with the
same size. We change the lookup method to use that.

* The use of tuples made the code slightly difficult to follow, as such we
unpack the tuple with structure binding to improve readability.

Depends on D152157

Differential Revision: https://reviews.llvm.org/D152158
  • Loading branch information
felipepiovezan committed Jun 8, 2023
1 parent b1ebfc5 commit 47755e1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,18 @@ AppleAcceleratorTable::Entry::Entry(

void AppleAcceleratorTable::Entry::extract(
const AppleAcceleratorTable &AccelTable, uint64_t *Offset) {
for (auto &Atom : Values)
Atom.extractValue(AccelTable.AccelSection, Offset, AccelTable.FormParams);
for (auto &FormValue : Values)
FormValue.extractValue(AccelTable.AccelSection, Offset,
AccelTable.FormParams);
}

std::optional<DWARFFormValue>
AppleAcceleratorTable::Entry::lookup(HeaderData::AtomType Atom) const {
AppleAcceleratorTable::Entry::lookup(HeaderData::AtomType AtomToFind) const {
assert(HdrData && "Dereferencing end iterator?");
assert(HdrData->Atoms.size() == Values.size());
for (auto Tuple : zip_first(HdrData->Atoms, Values)) {
if (std::get<0>(Tuple).first == Atom)
return std::get<1>(Tuple);
}
for (auto [Atom, FormValue] : zip_equal(HdrData->Atoms, Values))
if (Atom.first == AtomToFind)
return FormValue;
return std::nullopt;
}

Expand Down

0 comments on commit 47755e1

Please sign in to comment.