From 319d7304c341293f46c1c664183547d12be4e2ae Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 29 Mar 2016 20:53:21 +0000 Subject: [PATCH] Simplify. NFC. llvm-svn: 264785 --- lld/ELF/DriverUtils.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp index f40cfdd5876a..91a63e01a6e0 100644 --- a/lld/ELF/DriverUtils.cpp +++ b/lld/ELF/DriverUtils.cpp @@ -99,20 +99,14 @@ std::string elf::findFromSearchPaths(StringRef Path) { // Searches a given library from input search paths, which are filled // from -L command line switches. Returns a path to an existent library file. std::string elf::searchLibrary(StringRef Path) { - std::vector Names; - if (Path[0] == ':') { - Names.push_back(Path.drop_front()); - } else { - if (!Config->Static) - Names.push_back(("lib" + Path + ".so").str()); - Names.push_back(("lib" + Path + ".a").str()); - } - for (const std::string &Name : Names) { - std::string S = findFromSearchPaths(Name); + if (Path.startswith(":")) + return findFromSearchPaths(Path.substr(1)); + if (!Config->Static) { + std::string S = findFromSearchPaths(("lib" + Path + ".so").str()); if (!S.empty()) return S; } - return ""; + return findFromSearchPaths(("lib" + Path + ".a").str()); } // Makes a path by concatenating Dir and File.