From: Dan Gohman Date: Thu, 27 May 2010 17:12:23 +0000 (+0000) Subject: Don't bother checking canRead() before calling getMagicNumber(); X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=130de9c0b49d98983a5eb059fb5a89896f58d533;p=oota-llvm.git Don't bother checking canRead() before calling getMagicNumber(); getMagicNumber() does its own error checking. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104851 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp index 6844530ce99..1235257b27e 100644 --- a/lib/System/Path.cpp +++ b/lib/System/Path.cpp @@ -136,26 +136,23 @@ sys::IdentifyFileType(const char *magic, unsigned length) { bool Path::isArchive() const { - if (canRead()) - return hasMagicNumber("!\012"); - return false; + return hasMagicNumber("!\012"); } bool Path::isDynamicLibrary() const { - if (canRead()) { - std::string Magic; - if (getMagicNumber(Magic, 64)) - switch (IdentifyFileType(Magic.c_str(), - static_cast(Magic.length()))) { - default: return false; - case Mach_O_FixedVirtualMemorySharedLib_FileType: - case Mach_O_DynamicallyLinkedSharedLib_FileType: - case Mach_O_DynamicallyLinkedSharedLibStub_FileType: - case ELF_SharedObject_FileType: - case COFF_FileType: return true; - } - } + std::string Magic; + if (getMagicNumber(Magic, 64)) + switch (IdentifyFileType(Magic.c_str(), + static_cast(Magic.length()))) { + default: return false; + case Mach_O_FixedVirtualMemorySharedLib_FileType: + case Mach_O_DynamicallyLinkedSharedLib_FileType: + case Mach_O_DynamicallyLinkedSharedLibStub_FileType: + case ELF_SharedObject_FileType: + case COFF_FileType: return true; + } + return false; }