Mark two methods const.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 10 Sep 2015 21:48:36 +0000 (21:48 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 10 Sep 2015 21:48:36 +0000 (21:48 +0000)
While at it, optimize getOffset a bit.

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

include/llvm/MC/StringTableBuilder.h

index 897d449254eab4d4d93909b6fe2b8aecb82d9736..3164351d65643ce8d123df3d1abd8548bfc19aaa 100644 (file)
@@ -48,16 +48,17 @@ public:
 
   /// \brief Get the offest of a string in the string table. Can only be used
   /// after the table is finalized.
-  size_t getOffset(StringRef s) {
+  size_t getOffset(StringRef s) const {
     assert(isFinalized());
-    assert(StringIndexMap.count(s) && "String is not in table!");
-    return StringIndexMap[s];
+    auto I = StringIndexMap.find(s);
+    assert(I != StringIndexMap.end() && "String is not in table!");
+    return I->second;
   }
 
   void clear();
 
 private:
-  bool isFinalized() {
+  bool isFinalized() const {
     return !StringTable.empty();
   }
 };