aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-09-23 06:11:24 +0000
committerChris Lattner <sabre@nondot.org>2005-09-23 06:11:24 +0000
commit7b5634d2135ca0bfb02767d872573f90a7d73128 (patch)
tree4c3741c0abe0c9d147824a1cb8cb6b45b3e547f3
parentf39421302171a9d3aef26bb42de2d46b7325cf9e (diff)
downloadexternal_llvm-7b5634d2135ca0bfb02767d872573f90a7d73128.zip
external_llvm-7b5634d2135ca0bfb02767d872573f90a7d73128.tar.gz
external_llvm-7b5634d2135ca0bfb02767d872573f90a7d73128.tar.bz2
Speed up isBytecodeLPath from 20s to .01s in common cases. This makes -native
not completely painful to use. Once we decide a directory has a bytecode library, we know it this function returns true, no need to scan entire directories. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23405 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/gccld/GenerateCode.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/tools/gccld/GenerateCode.cpp b/tools/gccld/GenerateCode.cpp
index 432fa9d..72a159a 100644
--- a/tools/gccld/GenerateCode.cpp
+++ b/tools/gccld/GenerateCode.cpp
@@ -148,49 +148,43 @@ static bool isBytecodeLibrary(const sys::Path &FullPath) {
}
static bool isBytecodeLPath(const std::string &LibPath) {
- bool isBytecodeLPath = false;
-
sys::Path LPath(LibPath);
- // Make sure it exists
- if (!LPath.exists())
- return isBytecodeLPath;
-
- // Make sure its a directory
+ // Make sure it exists and is a directory
try {
- if (!LPath.isDirectory())
- return isBytecodeLPath;
+ if (!LPath.exists() || !LPath.isDirectory())
+ return false;
} catch (std::string& xcptn) {
- return isBytecodeLPath;
+ return false;
}
-
+
// Grab the contents of the -L path
std::set<sys::Path> Files;
LPath.getDirectoryContents(Files);
-
+
// Iterate over the contents one by one to determine
// if this -L path has any bytecode shared libraries
// or archives
std::set<sys::Path>::iterator File = Files.begin();
+ std::string dllsuffix = sys::Path::GetDLLSuffix();
for (; File != Files.end(); ++File) {
if ( File->isDirectory() )
continue;
std::string path = File->toString();
- std::string dllsuffix = sys::Path::GetDLLSuffix();
// Check for an ending '.dll,.so' or '.a' suffix as all
// other files are not of interest to us here
- if ( path.find(dllsuffix, path.size()-dllsuffix.size()) == std::string::npos
- && path.find(".a", path.size()-2) == std::string::npos )
+ if (path.find(dllsuffix, path.size()-dllsuffix.size()) == std::string::npos
+ && path.find(".a", path.size()-2) == std::string::npos)
continue;
// Finally, check to see if the file is a true bytecode file
if (isBytecodeLibrary(*File))
- isBytecodeLPath = true;
+ return true;
}
- return isBytecodeLPath;
+ return false;
}
/// GenerateBytecode - generates a bytecode file from the specified module.