]> granicus.if.org Git - clang/commitdiff
Add a new getLength() method to IdentifierInfo, which relies on a newly added
authorChris Lattner <sabre@nondot.org>
Sun, 30 Sep 2007 08:32:27 +0000 (08:32 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 30 Sep 2007 08:32:27 +0000 (08:32 +0000)
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

index b98cd9517a09e2dcf7f27e4083d01caf897d1e74..878f23788e8fafc87c6d6ee45b4b8c6c461e3582 100644 (file)
@@ -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<IdentifierInfo>::
+                  GetStringMapEntryFromValue(*this).getKeyData();
+  }
+  
+  /// getLength - Efficiently return the length of this identifier info.
+  ///
+  unsigned getLength() const {
+    return llvm::StringMapEntry<IdentifierInfo>::
+                    GetStringMapEntryFromValue(*this).getKeyLength();
   }
   
   /// getMacroInfo - Return macro information about this identifier, or null if