diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build.cc | 15 | ||||
-rw-r--r-- | src/build.h | 3 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/build.cc b/src/build.cc index 574aecc..c51ce53 100644 --- a/src/build.cc +++ b/src/build.cc @@ -278,7 +278,7 @@ bool Plan::AddSubTarget(Node* node, vector<Node*>* stack, string* err) { return false; } - if (CheckDependencyCycle(node, stack, err)) + if (CheckDependencyCycle(node, *stack, err)) return false; if (edge->outputs_ready()) @@ -316,15 +316,16 @@ bool Plan::AddSubTarget(Node* node, vector<Node*>* stack, string* err) { return true; } -bool Plan::CheckDependencyCycle(Node* node, vector<Node*>* stack, string* err) { - vector<Node*>::reverse_iterator ri = - find(stack->rbegin(), stack->rend(), node); - if (ri == stack->rend()) +bool Plan::CheckDependencyCycle(Node* node, const vector<Node*>& stack, + string* err) { + vector<Node*>::const_reverse_iterator ri = + find(stack.rbegin(), stack.rend(), node); + if (ri == stack.rend()) return false; - vector<Node*>::iterator start = find(stack->begin(), stack->end(), node); + vector<Node*>::const_iterator start = find(stack.begin(), stack.end(), node); *err = "dependency cycle: "; - for (vector<Node*>::iterator i = start; i != stack->end(); ++i) { + for (vector<Node*>::const_iterator i = start; i != stack.end(); ++i) { err->append((*i)->path()); err->append(" -> "); } diff --git a/src/build.h b/src/build.h index 5d5db80..4b48c5f 100644 --- a/src/build.h +++ b/src/build.h @@ -69,7 +69,8 @@ struct Plan { private: bool AddSubTarget(Node* node, vector<Node*>* stack, string* err); - bool CheckDependencyCycle(Node* node, vector<Node*>* stack, string* err); + bool CheckDependencyCycle(Node* node, const vector<Node*>& stack, + string* err); void NodeFinished(Node* node); /// Submits a ready edge as a candidate for execution. |