[cfe-commits] r42481 - /cfe/trunk/include/clang/Lex/IdentifierTable.h

Chris Lattner sabre at nondot.org
Sun Sep 30 01:32:27 PDT 2007


Author: lattner
Date: Sun Sep 30 03:32:27 2007
New Revision: 42481

URL: http://llvm.org/viewvc/llvm-project?rev=42481&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Lex/IdentifierTable.h

Modified: cfe/trunk/include/clang/Lex/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/IdentifierTable.h?rev=42481&r1=42480&r2=42481&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Lex/IdentifierTable.h Sun Sep 30 03:32:27 2007
@@ -53,8 +53,17 @@
   /// 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





More information about the cfe-commits mailing list