Simplify.

llvm-svn: 316144
This commit is contained in:
Rafael Espindola 2017-10-19 01:32:18 +00:00
parent 55680d0add
commit deaba3862f
1 changed files with 2 additions and 2 deletions

View File

@ -185,8 +185,8 @@ file_magic llvm::identify_magic(StringRef Magic) {
if (startswith(Magic, "MZ") && Magic.size() >= 0x3c + 4) {
uint32_t off = read32le(Magic.data() + 0x3c);
// PE/COFF file, either EXE or DLL.
if (off + sizeof(COFF::PEMagic) <= Magic.size() &&
memcmp(Magic.data() + off, COFF::PEMagic, sizeof(COFF::PEMagic)) == 0)
if (Magic.substr(off).startswith(
StringRef(COFF::PEMagic, sizeof(COFF::PEMagic))))
return file_magic::pecoff_executable;
}
break;