[llvm] r185680 - Use the raw member names in Archive::Archive.

Rafael Espindola rafael.espindola at gmail.com
Thu Jul 4 20:35:16 PDT 2013


Author: rafael
Date: Thu Jul  4 22:35:15 2013
New Revision: 185680

URL: http://llvm.org/viewvc/llvm-project?rev=185680&view=rev
Log:
Use the raw member names in Archive::Archive.

This a bit more efficient and avoids having a function that uses the string
table being called by a function that searches for it.

Modified:
    llvm/trunk/include/llvm/Object/Archive.h
    llvm/trunk/lib/Object/Archive.cpp

Modified: llvm/trunk/include/llvm/Object/Archive.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Archive.h?rev=185680&r1=185679&r2=185680&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/Archive.h (original)
+++ llvm/trunk/include/llvm/Object/Archive.h Thu Jul  4 22:35:15 2013
@@ -114,6 +114,7 @@ public:
     }
 
     error_code getName(StringRef &Result) const;
+    StringRef getRawName() const { return ToHeader(Data.data())->getName(); }
     int getLastModified() const;
     int getUID() const;
     int getGID() const;

Modified: llvm/trunk/lib/Object/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=185680&r1=185679&r2=185680&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Archive.cpp (original)
+++ llvm/trunk/lib/Object/Archive.cpp Thu Jul  4 22:35:15 2013
@@ -38,7 +38,7 @@ static bool isInternalMember(const Archi
 void Archive::anchor() { }
 
 error_code Archive::Child::getName(StringRef &Result) const {
-  StringRef name = ToHeader(Data.data())->getName();
+  StringRef name = getRawName();
   // Check if it's a special name.
   if (name[0] == '/') {
     if (name.size() == 1) { // Linker member.
@@ -119,10 +119,7 @@ Archive::Archive(MemoryBuffer *source, e
     return;
   }
 
-  // FIXME: this function should be able to use raw names.
-  StringRef name;
-  if ((ec = i->getName(name)))
-    return;
+  StringRef Name = i->getRawName();
 
   // Below is the pattern that is used to figure out the archive format
   // GNU archive format
@@ -143,14 +140,14 @@ Archive::Archive(MemoryBuffer *source, e
   //  seem to create the third member if there's no member whose filename
   //  exceeds 15 characters. So the third member is optional.
 
-  if (name == "__.SYMDEF") {
+  if (Name == "__.SYMDEF") {
     Format = K_BSD;
     SymbolTable = i;
     ec = object_error::success;
     return;
   }
 
-  if (name == "/") {
+  if (Name == "/") {
     SymbolTable = i;
 
     ++i;
@@ -158,24 +155,23 @@ Archive::Archive(MemoryBuffer *source, e
       ec = object_error::parse_failed;
       return;
     }
-    if ((ec = i->getName(name)))
-      return;
+    Name = i->getRawName();
   }
 
-  if (name == "//") {
+  if (Name == "//") {
     Format = K_GNU;
     StringTable = i;
     ec = object_error::success;
     return;
   }
 
-  if (name[0] != '/') {
+  if (Name[0] != '/') {
     Format = K_GNU;
     ec = object_error::success;
     return;
   }
 
-  if (name != "/") {
+  if (Name != "/") {
     ec = object_error::parse_failed;
     return;
   }
@@ -189,10 +185,9 @@ Archive::Archive(MemoryBuffer *source, e
     return;
   }
 
-  if ((ec = i->getName(name)))
-    return;
+  Name = i->getRawName();
 
-  if (name == "//")
+  if (Name == "//")
     StringTable = i;
 
   ec = object_error::success;





More information about the llvm-commits mailing list