[PATCH] D152158: [AppleAccelTable][NFC] Improve code readability

Felipe de Azevedo Piovezan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 5 06:45:40 PDT 2023


fdeazeve created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
fdeazeve requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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 <https://reviews.llvm.org/D152157>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152158

Files:
  llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp


Index: llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -275,18 +275,18 @@
 
 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;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152158.528414.patch
Type: text/x-patch
Size: 1216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230605/3a28a4e6/attachment.bin>


More information about the llvm-commits mailing list