[lld] r208256 - Simplify InputGraph::getNextFile. No functionality change.
Rui Ueyama
ruiu at google.com
Wed May 7 15:27:12 PDT 2014
Author: ruiu
Date: Wed May 7 17:27:12 2014
New Revision: 208256
URL: http://llvm.org/viewvc/llvm-project?rev=208256&view=rev
Log:
Simplify InputGraph::getNextFile. No functionality change.
Modified:
lld/trunk/lib/Core/InputGraph.cpp
Modified: lld/trunk/lib/Core/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=208256&r1=208255&r2=208256&view=diff
==============================================================================
--- lld/trunk/lib/Core/InputGraph.cpp (original)
+++ lld/trunk/lib/Core/InputGraph.cpp Wed May 7 17:27:12 2014
@@ -16,29 +16,20 @@
using namespace lld;
ErrorOr<File &> InputGraph::getNextFile() {
- // When getNextFile() is called for the first time, _currentInputElement is
- // not initialized. Initialize it with the first element of the input graph.
- if (_currentInputElement == nullptr) {
- ErrorOr<InputElement *> elem = getNextInputElement();
- if (elem.getError() == InputGraphError::no_more_elements)
- return make_error_code(InputGraphError::no_more_files);
- _currentInputElement = *elem;
- }
-
- // Otherwise, try to get the next file of _currentInputElement. If the current
- // input element points to an archive file, and there's a file left in the
- // archive, it will succeed. If not, try to get the next file in the input
- // graph.
+ // Try to get the next file of _currentInputElement. If the current input
+ // element points to an archive file, and there's a file left in the archive,
+ // it will succeed. If not, try to get the next file in the input graph.
for (;;) {
- ErrorOr<File &> nextFile = _currentInputElement->getNextFile();
- if (nextFile.getError() != InputGraphError::no_more_files)
- return std::move(nextFile);
+ if (_currentInputElement) {
+ ErrorOr<File &> nextFile = _currentInputElement->getNextFile();
+ if (nextFile.getError() != InputGraphError::no_more_files)
+ return std::move(nextFile);
+ }
- ErrorOr<InputElement *> elem = getNextInputElement();
- if (elem.getError() == InputGraphError::no_more_elements ||
- *elem == nullptr)
+ ErrorOr<InputElement *> elt = getNextInputElement();
+ if (elt.getError() == InputGraphError::no_more_elements || *elt == nullptr)
return make_error_code(InputGraphError::no_more_files);
- _currentInputElement = *elem;
+ _currentInputElement = *elt;
}
}
More information about the llvm-commits
mailing list