Small adjustment to PlatformDarwinKernel::ExamineKextForMatchingUUID to

help performance -- if the FileSpec we're examining does not contain the
UUID we're looking for, don't bother examining the file any further.

llvm-svn: 181063
This commit is contained in:
Jason Molenda 2013-05-03 22:28:10 +00:00
parent 55be0c840e
commit 60e58967f9
1 changed files with 11 additions and 3 deletions

View File

@ -630,10 +630,18 @@ PlatformDarwinKernel::ExamineKextForMatchingUUID (const FileSpec &kext_bundle_pa
ModuleSpec exe_spec (exe_file);
exe_spec.GetUUID() = uuid;
exe_spec.GetArchitecture() = arch;
error = ModuleList::GetSharedModule (exe_spec, exe_module_sp, NULL, NULL, NULL);
if (exe_module_sp && exe_module_sp->GetObjectFile())
// First try to create a ModuleSP with the file / arch and see if the UUID matches.
// If that fails (this exec file doesn't have the correct uuid), don't call GetSharedModule
// (which may call in to the DebugSymbols framework and therefore can be slow.)
ModuleSP module_sp (new Module (exe_file, arch));
if (module_sp && module_sp->GetObjectFile() && module_sp->MatchesModuleSpec (exe_spec))
{
return error;
error = ModuleList::GetSharedModule (exe_spec, exe_module_sp, NULL, NULL, NULL);
if (exe_module_sp && exe_module_sp->GetObjectFile())
{
return error;
}
}
exe_module_sp.reset();
}