Remember that we have a null terminated string.

This is a micro optimization. Instead of going char*->StringRef->Twine->char*,
go char*->Twine->char* and avoid having to copy the filename on the stack.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186380 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2013-07-16 03:30:10 +00:00
parent 20a91bfd36
commit 289e241d77

View File

@ -387,7 +387,7 @@ public:
NewArchiveIterator(std::vector<std::string>::const_iterator I, Twine Name);
bool isNewMember() const;
object::Archive::child_iterator getOld() const;
StringRef getNew() const;
const char *getNew() const;
StringRef getMemberName() const { return MemberName; }
};
}
@ -411,9 +411,9 @@ object::Archive::child_iterator NewArchiveIterator::getOld() const {
return OldI;
}
StringRef NewArchiveIterator::getNew() const {
const char *NewArchiveIterator::getNew() const {
assert(IsNewMember);
return *NewI;
return NewI->c_str();
}
template <typename T>
@ -556,7 +556,7 @@ static void performWriteOperation(ArchiveOperation Operation,
if (I->isNewMember()) {
// FIXME: we do a stat + open. We should do a open + fstat.
StringRef FileName = I->getNew();
const char *FileName = I->getNew();
sys::fs::file_status Status;
failIfError(sys::fs::status(FileName, Status), FileName);