[Serialization] Fix caching of deserialized Identifiers (#19264)

This was causing us to do a string table lookup on every use of a
serialized identifier, even a repeated one.
This commit is contained in:
Jordan Rose
2018-09-12 14:49:01 -07:00
committed by GitHub
parent 0149129ed3
commit 8da411b606

View File

@@ -1736,7 +1736,7 @@ DeclBaseName ModuleFile::getDeclBaseName(IdentifierID IID) {
size_t rawID = IID - NUM_SPECIAL_IDS;
assert(rawID < Identifiers.size() && "invalid identifier ID");
auto identRecord = Identifiers[rawID];
auto &identRecord = Identifiers[rawID];
if (identRecord.Offset == 0)
return identRecord.Ident;
@@ -1748,7 +1748,11 @@ DeclBaseName ModuleFile::getDeclBaseName(IdentifierID IID) {
assert(terminatorOffset != StringRef::npos &&
"unterminated identifier string data");
return getContext().getIdentifier(rawStrPtr.slice(0, terminatorOffset));
// Cache the resulting identifier.
identRecord.Ident =
getContext().getIdentifier(rawStrPtr.slice(0, terminatorOffset));
identRecord.Offset = 0;
return identRecord.Ident;
}
Identifier ModuleFile::getIdentifier(IdentifierID IID) {