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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185680 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2013-07-05 03:35:15 +00:00
parent a5db79d514
commit 4a0bf5423c
2 changed files with 11 additions and 15 deletions

View File

@@ -114,6 +114,7 @@ public:
} }
error_code getName(StringRef &Result) const; error_code getName(StringRef &Result) const;
StringRef getRawName() const { return ToHeader(Data.data())->getName(); }
int getLastModified() const; int getLastModified() const;
int getUID() const; int getUID() const;
int getGID() const; int getGID() const;

View File

@@ -38,7 +38,7 @@ static bool isInternalMember(const ArchiveMemberHeader &amh) {
void Archive::anchor() { } void Archive::anchor() { }
error_code Archive::Child::getName(StringRef &Result) const { error_code Archive::Child::getName(StringRef &Result) const {
StringRef name = ToHeader(Data.data())->getName(); StringRef name = getRawName();
// Check if it's a special name. // Check if it's a special name.
if (name[0] == '/') { if (name[0] == '/') {
if (name.size() == 1) { // Linker member. if (name.size() == 1) { // Linker member.
@@ -119,10 +119,7 @@ Archive::Archive(MemoryBuffer *source, error_code &ec)
return; return;
} }
// FIXME: this function should be able to use raw names. StringRef Name = i->getRawName();
StringRef name;
if ((ec = i->getName(name)))
return;
// Below is the pattern that is used to figure out the archive format // Below is the pattern that is used to figure out the archive format
// GNU archive format // GNU archive format
@@ -143,14 +140,14 @@ Archive::Archive(MemoryBuffer *source, error_code &ec)
// seem to create the third member if there's no member whose filename // seem to create the third member if there's no member whose filename
// exceeds 15 characters. So the third member is optional. // exceeds 15 characters. So the third member is optional.
if (name == "__.SYMDEF") { if (Name == "__.SYMDEF") {
Format = K_BSD; Format = K_BSD;
SymbolTable = i; SymbolTable = i;
ec = object_error::success; ec = object_error::success;
return; return;
} }
if (name == "/") { if (Name == "/") {
SymbolTable = i; SymbolTable = i;
++i; ++i;
@@ -158,24 +155,23 @@ Archive::Archive(MemoryBuffer *source, error_code &ec)
ec = object_error::parse_failed; ec = object_error::parse_failed;
return; return;
} }
if ((ec = i->getName(name))) Name = i->getRawName();
return;
} }
if (name == "//") { if (Name == "//") {
Format = K_GNU; Format = K_GNU;
StringTable = i; StringTable = i;
ec = object_error::success; ec = object_error::success;
return; return;
} }
if (name[0] != '/') { if (Name[0] != '/') {
Format = K_GNU; Format = K_GNU;
ec = object_error::success; ec = object_error::success;
return; return;
} }
if (name != "/") { if (Name != "/") {
ec = object_error::parse_failed; ec = object_error::parse_failed;
return; return;
} }
@@ -189,10 +185,9 @@ Archive::Archive(MemoryBuffer *source, error_code &ec)
return; return;
} }
if ((ec = i->getName(name))) Name = i->getRawName();
return;
if (name == "//") if (Name == "//")
StringTable = i; StringTable = i;
ec = object_error::success; ec = object_error::success;