[PATCH] Remove unused enum Position::ANY and third parameter of insertElementAt().

Rui Ueyama ruiu at google.com
Tue Apr 1 16:56:59 PDT 2014


Hi Bigcheese, shankarke, kledzik,

insertElementAt()'s third parameter is not only unused but also ignored
if you pass Position::END. The actual meaning of the parameter was obscure.

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

Files:
  include/lld/Core/InputGraph.h
  lib/Core/InputGraph.cpp

Index: include/lld/Core/InputGraph.h
===================================================================
--- include/lld/Core/InputGraph.h
+++ include/lld/Core/InputGraph.h
@@ -49,11 +49,7 @@
 
   /// Where do we want to insert the input element when calling the
   /// insertElementAt.
-  enum Position : uint8_t {
-    ANY,
-    BEGIN,
-    END
-  };
+  enum Position : uint8_t { BEGIN, END };
 
   /// \brief Initialize the inputgraph
   InputGraph() : _ordinal(0), _nextElementIndex(0) {}
@@ -91,8 +87,7 @@
   }
 
   /// \brief Insert an element into the input graph at position.
-  void insertElementAt(std::unique_ptr<InputElement>, Position position,
-                       size_t pos = 0);
+  void insertElementAt(std::unique_ptr<InputElement>, Position position);
 
   /// \brief Helper functions for the resolver
   ErrorOr<InputElement *> getNextInputElement();
Index: lib/Core/InputGraph.cpp
===================================================================
--- lib/Core/InputGraph.cpp
+++ lib/Core/InputGraph.cpp
@@ -44,12 +44,13 @@
 
 /// \brief Insert element at position
 void InputGraph::insertElementAt(std::unique_ptr<InputElement> element,
-                                 Position position, size_t pos) {
-  if (position == InputGraph::Position::BEGIN)
-    pos = 0;
-  else if (position == InputGraph::Position::END)
-    pos = _inputArgs.size();
-  _inputArgs.insert(_inputArgs.begin() + pos, std::move(element));
+                                 Position position) {
+  if (position == InputGraph::Position::BEGIN) {
+    _inputArgs.insert(_inputArgs.begin(), std::move(element));
+    return;
+  }
+  assert(position == InputGraph::Position::END);
+  _inputArgs.push_back(std::move(element));
 }
 
 /// \brief Helper functions for the resolver
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3256.1.patch
Type: text/x-patch
Size: 1774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140401/081a802f/attachment.bin>


More information about the llvm-commits mailing list