Change std::vector to SmallVector<4> and remove some unused methods.
authorEli Bendersky <eliben@google.com>
Wed, 5 Dec 2012 22:11:02 +0000 (22:11 +0000)
committerEli Bendersky <eliben@google.com>
Wed, 5 Dec 2012 22:11:02 +0000 (22:11 +0000)
This is more consistent with other vectors in this code. In addition, I ran some
tests compiling a large program and >96% of fragments have 4 or less fixups, so
SmallVector<4> is a good optimization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169433 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCAssembler.h
lib/MC/MCAssembler.cpp

index 057faac91a2013166f200938560af248bf1cfeb5..266e0c7f4842abf6137b23aa38d7c15df6b210e5 100644 (file)
@@ -107,11 +107,11 @@ class MCDataFragment : public MCFragment {
   SmallString<32> Contents;
 
   /// Fixups - The list of fixups in this fragment.
-  std::vector<MCFixup> Fixups;
+  SmallVector<MCFixup, 4> Fixups;
 
 public:
-  typedef std::vector<MCFixup>::const_iterator const_fixup_iterator;
-  typedef std::vector<MCFixup>::iterator fixup_iterator;
+  typedef SmallVectorImpl<MCFixup>::const_iterator const_fixup_iterator;
+  typedef SmallVectorImpl<MCFixup>::iterator fixup_iterator;
 
 public:
   MCDataFragment(MCSectionData *SD = 0) : MCFragment(FT_Data, SD) {}
@@ -133,9 +133,6 @@ public:
     Fixups.push_back(Fixup);
   }
 
-  std::vector<MCFixup> &getFixups() { return Fixups; }
-  const std::vector<MCFixup> &getFixups() const { return Fixups; }
-
   fixup_iterator fixup_begin() { return Fixups.begin(); }
   const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
 
index 48aec668bf8946d5788d3067e027f374a2e22f5b..457abd2a0aaa47aa991848ae442e5c84647fd7c0 100644 (file)
@@ -870,7 +870,7 @@ void MCFragment::dump() {
     }
     OS << "] (" << Contents.size() << " bytes)";
 
-    if (!DF->getFixups().empty()) {
+    if (DF->fixup_begin() != DF->fixup_end()) {
       OS << ",\n       ";
       OS << " Fixups:[";
       for (MCDataFragment::const_fixup_iterator it = DF->fixup_begin(),