[lld] r196200 - Simplify a switch statement.
Rui Ueyama
ruiu at google.com
Mon Dec 2 20:18:55 PST 2013
Author: ruiu
Date: Mon Dec 2 22:18:55 2013
New Revision: 196200
URL: http://llvm.org/viewvc/llvm-project?rev=196200&view=rev
Log:
Simplify a switch statement.
Modified:
lld/trunk/lib/Driver/WinLinkInputGraph.cpp
Modified: lld/trunk/lib/Driver/WinLinkInputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkInputGraph.cpp?rev=196200&r1=196199&r2=196200&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkInputGraph.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkInputGraph.cpp Mon Dec 2 22:18:55 2013
@@ -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 L
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<File> 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<File>(
+ 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<File &> PECOFFFileNode::getNextFile() {
More information about the llvm-commits
mailing list