[PATCH] Inline short function using lambda to improve readability.

Rui Ueyama ruiu at google.com
Thu Apr 3 18:21:22 PDT 2014


Hi Bigcheese, shankarke, kledzik,

Inline short function using lambda to improve readability.

http://llvm-reviews.chandlerc.com/D3286

Files:
  lib/Core/Resolver.cpp

Index: lib/Core/Resolver.cpp
===================================================================
--- lib/Core/Resolver.cpp
+++ lib/Core/Resolver.cpp
@@ -29,24 +29,6 @@
 
 namespace lld {
 
-namespace {
-
-/// This is used as a filter function to std::remove_if to coalesced atoms.
-class AtomCoalescedAway {
-public:
-  explicit AtomCoalescedAway(SymbolTable &sym) : _symbolTable(sym) {}
-
-  bool operator()(const Atom *atom) const {
-    const Atom *rep = _symbolTable.replacement(atom);
-    return rep != atom;
-  }
-
-private:
-  SymbolTable &_symbolTable;
-};
-
-} // namespace
-
 void Resolver::handleFile(const File &file) {
   bool isEmpty = file.defined().empty() && file.undefined().empty() &&
                  file.sharedLibrary().empty() && file.absolute().empty();
@@ -403,9 +385,11 @@
 // remove from _atoms all coaleseced away atoms
 void Resolver::removeCoalescedAwayAtoms() {
   ScopedTask task(getDefaultDomain(), "removeCoalescedAwayAtoms");
-  _atoms.erase(std::remove_if(_atoms.begin(), _atoms.end(),
-                              AtomCoalescedAway(_symbolTable)),
-               _atoms.end());
+  _atoms.erase(
+      std::remove_if(_atoms.begin(), _atoms.end(), [&](const Atom *atom) {
+        return _symbolTable.replacement(atom) != atom;
+      }),
+      _atoms.end());
 }
 
 bool Resolver::resolve() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3286.1.patch
Type: text/x-patch
Size: 1335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140403/b30baf03/attachment.bin>


More information about the llvm-commits mailing list