From eb5162f2ad5821723fcdd3e343f7778efff19442 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 3 Dec 2013 04:18:55 +0000 Subject: [PATCH] Simplify a switch statement. llvm-svn: 196200 --- lld/lib/Driver/WinLinkInputGraph.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lld/lib/Driver/WinLinkInputGraph.cpp b/lld/lib/Driver/WinLinkInputGraph.cpp index 74ca0b149cc1..eebebf4a9d6b 100644 --- a/lld/lib/Driver/WinLinkInputGraph.cpp +++ b/lld/lib/Driver/WinLinkInputGraph.cpp @@ -9,6 +9,9 @@ #include "lld/Driver/WinLinkInputGraph.h" +using llvm::sys::fs::file_magic; +using llvm::sys::fs::identify_magic; + namespace lld { /// \brief Parse the input file to lld::File. @@ -30,23 +33,14 @@ error_code PECOFFFileNode::parse(const LinkingContext &ctx, if (filePath->endswith(".objtxt")) return ctx.getYAMLReader().parseFile(_buffer, _files); - - llvm::sys::fs::file_magic FileType = - llvm::sys::fs::identify_magic(_buffer->getBuffer()); - std::unique_ptr f; - - switch (FileType) { - case llvm::sys::fs::file_magic::archive: { + if (identify_magic(_buffer->getBuffer()) == file_magic::archive) { // Archive File error_code ec; - f.reset(new FileArchive(ctx, std::move(_buffer), ec, false)); - _files.push_back(std::move(f)); + _files.push_back(std::unique_ptr( + new FileArchive(ctx, std::move(_buffer), ec, false))); return ec; } - case llvm::sys::fs::file_magic::coff_object: - default: - return _ctx.getDefaultReader().parseFile(_buffer, _files); - } + return _ctx.getDefaultReader().parseFile(_buffer, _files); } ErrorOr PECOFFFileNode::getNextFile() {