From 1f945f632ae993bbb9f9e69d908f7526924c1a88 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 30 Sep 2007 08:32:27 +0000 Subject: [PATCH] Add a new getLength() method to IdentifierInfo, which relies on a newly added method to StringMapEntry. Steve, please use this to remove the strlen calls in selector processing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42481 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Lex/IdentifierTable.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/clang/Lex/IdentifierTable.h b/include/clang/Lex/IdentifierTable.h index b98cd9517a..878f23788e 100644 --- a/include/clang/Lex/IdentifierTable.h +++ b/include/clang/Lex/IdentifierTable.h @@ -53,8 +53,17 @@ public: /// string is properly null terminated. /// const char *getName() const { - // String data is stored immediately after the IdentifierInfo object. - return (const char*)(this+1); + // We know that this is embedded into a StringMapEntry, and it knows how to + // efficiently find the string. + return llvm::StringMapEntry:: + GetStringMapEntryFromValue(*this).getKeyData(); + } + + /// getLength - Efficiently return the length of this identifier info. + /// + unsigned getLength() const { + return llvm::StringMapEntry:: + GetStringMapEntryFromValue(*this).getKeyLength(); } /// getMacroInfo - Return macro information about this identifier, or null if -- 2.40.0