From db8a4a8578af7703937c30b47ee3ffc9a952e6b4 Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Wed, 30 Apr 2014 19:03:56 +0000 Subject: [ELF] Return result from the function ASAP. No functional changes. llvm-svn: 207690 --- lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp') diff --git a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp index 7157df03b72..b3904bc8d86 100644 --- a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp @@ -226,30 +226,20 @@ static void buildSearchPath(SmallString<128> &path, StringRef dir, } ErrorOr 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); -- cgit v1.2.3