[lld] r207690 - [ELF] Return result from the function ASAP.
Simon Atanasyan
simon at atanasyan.com
Wed Apr 30 12:03:56 PDT 2014
Author: atanasyan
Date: Wed Apr 30 14:03:56 2014
New Revision: 207690
URL: http://llvm.org/viewvc/llvm-project?rev=207690&view=rev
Log:
[ELF] Return result from the function ASAP.
No functional changes.
Modified:
lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=207690&r1=207689&r2=207690&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Wed Apr 30 14:03:56 2014
@@ -226,30 +226,20 @@ static void buildSearchPath(SmallString<
}
ErrorOr<StringRef> ELFLinkingContext::searchLibrary(StringRef libName) const {
- bool foundFile = false;
- StringRef pathref;
SmallString<128> path;
for (StringRef dir : _inputSearchPaths) {
// Search for dynamic library
if (!_isStaticExecutable) {
buildSearchPath(path, dir, _sysrootPath);
llvm::sys::path::append(path, Twine("lib") + libName + ".so");
- pathref = path.str();
- if (llvm::sys::fs::exists(pathref)) {
- foundFile = true;
- }
+ if (llvm::sys::fs::exists(path.str()))
+ return StringRef(*new (_allocator) std::string(path.str()));
}
// Search for static libraries too
- if (!foundFile) {
- buildSearchPath(path, dir, _sysrootPath);
- llvm::sys::path::append(path, Twine("lib") + libName + ".a");
- pathref = path.str();
- if (llvm::sys::fs::exists(pathref)) {
- foundFile = true;
- }
- }
- if (foundFile)
- return StringRef(*new (_allocator) std::string(pathref));
+ buildSearchPath(path, dir, _sysrootPath);
+ llvm::sys::path::append(path, Twine("lib") + libName + ".a");
+ if (llvm::sys::fs::exists(path.str()))
+ return StringRef(*new (_allocator) std::string(path.str()));
}
if (!llvm::sys::fs::exists(libName))
return llvm::make_error_code(llvm::errc::no_such_file_or_directory);
More information about the llvm-commits
mailing list