[llvm] r247342 - Mark two methods const.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 14:48:36 PDT 2015
Author: rafael
Date: Thu Sep 10 16:48:36 2015
New Revision: 247342
URL: http://llvm.org/viewvc/llvm-project?rev=247342&view=rev
Log:
Mark two methods const.
While at it, optimize getOffset a bit.
Modified:
llvm/trunk/include/llvm/MC/StringTableBuilder.h
Modified: llvm/trunk/include/llvm/MC/StringTableBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/StringTableBuilder.h?rev=247342&r1=247341&r2=247342&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/StringTableBuilder.h (original)
+++ llvm/trunk/include/llvm/MC/StringTableBuilder.h Thu Sep 10 16:48:36 2015
@@ -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();
}
};
More information about the llvm-commits
mailing list