[Serialization] getIdentifierText, for when an Identifier isn't needed

Not everything that goes into the "identifier table" is actually an
Identifier. If we don't need the string to be uniqued in the
ASTContext, don't bother calling getIdentifier.

May save some memory usage (and a string table lookup) for
deserialization.
This commit is contained in:
Jordan Rose
2018-09-12 09:05:27 -07:00
parent c7187d69af
commit 2ee8d1a4ad
3 changed files with 66 additions and 49 deletions

View File

@@ -314,11 +314,11 @@ private:
/// Represents an identifier that may or may not have been deserialized yet.
///
/// If \c Offset is non-zero, the identifier has not been loaded yet.
/// If \c Ident is empty, the identifier has not been loaded yet.
class SerializedIdentifier {
public:
Identifier Ident;
serialization::BitOffset Offset;
unsigned Offset;
template <typename IntTy>
/*implicit*/ SerializedIdentifier(IntTy rawOffset)
@@ -793,6 +793,11 @@ public:
/// given ID. Asserts that the name with this ID is not special.
Identifier getIdentifier(serialization::IdentifierID IID);
/// Convenience method to retrieve the text of the name with the given ID.
/// This can be used if the result doesn't need to be uniqued in the
/// ASTContext. Asserts that the name with this ID is not special.
StringRef getIdentifierText(serialization::IdentifierID IID);
/// Returns the decl with the given ID, deserializing it if needed.
///
/// \param DID The ID for the decl within this module.