[llvm] r253267 - Demote a single-use named function object to a lambda

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 14:56:31 PST 2015


Author: dblaikie
Date: Mon Nov 16 16:56:30 2015
New Revision: 253267

URL: http://llvm.org/viewvc/llvm-project?rev=253267&view=rev
Log:
Demote a single-use named function object to a lambda

Modified:
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=253267&r1=253266&r2=253267&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Mon Nov 16 16:56:30 2015
@@ -53,14 +53,6 @@ protected:
 template<typename UnitType>
 class DWARFUnitSection final : public SmallVector<std::unique_ptr<UnitType>, 1>,
                                public DWARFUnitSectionBase {
-
-  struct UnitOffsetComparator {
-    bool operator()(uint32_t LHS,
-                    const std::unique_ptr<UnitType> &RHS) const {
-      return LHS < RHS->getNextUnitOffset();
-    }
-  };
-
   bool Parsed;
 
 public:
@@ -73,8 +65,11 @@ public:
   typedef llvm::iterator_range<typename UnitVector::iterator> iterator_range;
 
   UnitType *getUnitForOffset(uint32_t Offset) const override {
-    auto *CU = std::upper_bound(this->begin(), this->end(), Offset,
-                                UnitOffsetComparator());
+    auto *CU = std::upper_bound(
+        this->begin(), this->end(), Offset,
+        [](uint32_t LHS, const std::unique_ptr<UnitType> &RHS) {
+          return LHS < RHS->getNextUnitOffset();
+        });
     if (CU != this->end())
       return CU->get();
     return nullptr;




More information about the llvm-commits mailing list