While at it, optimize getOffset a bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247342
91177308-0d34-0410-b5e6-
96231b3b80d8
/// \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();
}
};