From 5b18c9f4a351396fb6584ccc5dd993a210ba528c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 10 Sep 2015 21:48:36 +0000 Subject: [PATCH] Mark two methods const. 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/llvm/MC/StringTableBuilder.h b/include/llvm/MC/StringTableBuilder.h index 897d449254e..3164351d656 100644 --- a/include/llvm/MC/StringTableBuilder.h +++ b/include/llvm/MC/StringTableBuilder.h @@ -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(); } }; -- 2.34.1