From a9dac57ecad0b8ff4822c39446e9bf35afc0a615 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 7 Dec 2014 14:49:49 -0800 Subject: Rename a few iterators. No behavior change. It confused me that the iterator iterating over `outputs_` was called `i` -- this always made me think of "input", not "iterator". Call iterators over edge outputs "o", iterators over edge inputs "i", iterators over node input edges "oe", and general iterators over edges "e". --- src/build.cc | 116 +++++++++++++++++++++++++++++------------------------------ src/graph.cc | 18 +++++----- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/build.cc b/src/build.cc index 3e74131..ba2f93d 100644 --- a/src/build.cc +++ b/src/build.cc @@ -339,9 +339,9 @@ bool Plan::CheckDependencyCycle(Node* node, vector* stack, string* err) { Edge* Plan::FindWork() { if (ready_.empty()) return NULL; - set::iterator i = ready_.begin(); - Edge* edge = *i; - ready_.erase(i); + set::iterator e = ready_.begin(); + Edge* edge = *e; + ready_.erase(e); return edge; } @@ -368,39 +368,39 @@ void Plan::ResumeDelayedJobs(Edge* edge) { } void Plan::EdgeFinished(Edge* edge) { - map::iterator i = want_.find(edge); - assert(i != want_.end()); - if (i->second) + map::iterator e = want_.find(edge); + assert(e != want_.end()); + if (e->second) --wanted_edges_; - want_.erase(i); + want_.erase(e); edge->outputs_ready_ = true; // See if this job frees up any delayed jobs ResumeDelayedJobs(edge); // Check off any nodes we were waiting for with this edge. - for (vector::iterator i = edge->outputs_.begin(); - i != edge->outputs_.end(); ++i) { - NodeFinished(*i); + for (vector::iterator o = edge->outputs_.begin(); + o != edge->outputs_.end(); ++o) { + NodeFinished(*o); } } void Plan::NodeFinished(Node* node) { // See if we we want any edges from this node. - for (vector::const_iterator i = node->out_edges().begin(); - i != node->out_edges().end(); ++i) { - map::iterator want_i = want_.find(*i); - if (want_i == want_.end()) + for (vector::const_iterator oe = node->out_edges().begin(); + oe != node->out_edges().end(); ++oe) { + map::iterator want_e = want_.find(*oe); + if (want_e == want_.end()) continue; // See if the edge is now ready. - if ((*i)->AllInputsReady()) { - if (want_i->second) { - ScheduleWork(*i); + if ((*oe)->AllInputsReady()) { + if (want_e->second) { + ScheduleWork(*oe); } else { // We do not need to build this edge, but we might need to build one of // its dependents. - EdgeFinished(*i); + EdgeFinished(*oe); } } } @@ -409,42 +409,42 @@ void Plan::NodeFinished(Node* node) { void Plan::CleanNode(DependencyScan* scan, Node* node) { node->set_dirty(false); - for (vector::const_iterator ei = node->out_edges().begin(); - ei != node->out_edges().end(); ++ei) { + for (vector::const_iterator oe = node->out_edges().begin(); + oe != node->out_edges().end(); ++oe) { // Don't process edges that we don't actually want. - map::iterator want_i = want_.find(*ei); - if (want_i == want_.end() || !want_i->second) + map::iterator want_e = want_.find(*oe); + if (want_e == want_.end() || !want_e->second) continue; // Don't attempt to clean an edge if it failed to load deps. - if ((*ei)->deps_missing_) + if ((*oe)->deps_missing_) continue; // If all non-order-only inputs for this edge are now clean, // we might have changed the dirty state of the outputs. vector::iterator - begin = (*ei)->inputs_.begin(), - end = (*ei)->inputs_.end() - (*ei)->order_only_deps_; + begin = (*oe)->inputs_.begin(), + end = (*oe)->inputs_.end() - (*oe)->order_only_deps_; if (find_if(begin, end, mem_fun(&Node::dirty)) == end) { // Recompute most_recent_input. Node* most_recent_input = NULL; - for (vector::iterator ni = begin; ni != end; ++ni) { - if (!most_recent_input || (*ni)->mtime() > most_recent_input->mtime()) - most_recent_input = *ni; + for (vector::iterator i = begin; i != end; ++i) { + if (!most_recent_input || (*i)->mtime() > most_recent_input->mtime()) + most_recent_input = *i; } // Now, this edge is dirty if any of the outputs are dirty. // If the edge isn't dirty, clean the outputs and mark the edge as not // wanted. - if (!scan->RecomputeOutputsDirty(*ei, most_recent_input)) { - for (vector::iterator ni = (*ei)->outputs_.begin(); - ni != (*ei)->outputs_.end(); ++ni) { - CleanNode(scan, *ni); + if (!scan->RecomputeOutputsDirty(*oe, most_recent_input)) { + for (vector::iterator o = (*oe)->outputs_.begin(); + o != (*oe)->outputs_.end(); ++o) { + CleanNode(scan, *o); } - want_i->second = false; + want_e->second = false; --wanted_edges_; - if (!(*ei)->is_phony()) + if (!(*oe)->is_phony()) --command_edges_; } } @@ -453,10 +453,10 @@ void Plan::CleanNode(DependencyScan* scan, Node* node) { void Plan::Dump() { printf("pending: %d\n", (int)want_.size()); - for (map::iterator i = want_.begin(); i != want_.end(); ++i) { - if (i->second) + for (map::iterator e = want_.begin(); e != want_.end(); ++e) { + if (e->second) printf("want "); - i->first->Dump(); + e->first->Dump(); } printf("ready: %d\n", (int)ready_.size()); } @@ -477,9 +477,9 @@ struct RealCommandRunner : public CommandRunner { vector RealCommandRunner::GetActiveEdges() { vector edges; - for (map::iterator i = subproc_to_edge_.begin(); - i != subproc_to_edge_.end(); ++i) - edges.push_back(i->second); + for (map::iterator e = subproc_to_edge_.begin(); + e != subproc_to_edge_.end(); ++e) + edges.push_back(e->second); return edges; } @@ -516,9 +516,9 @@ bool RealCommandRunner::WaitForCommand(Result* result) { result->status = subproc->Finish(); result->output = subproc->GetOutput(); - map::iterator i = subproc_to_edge_.find(subproc); - result->edge = i->second; - subproc_to_edge_.erase(i); + map::iterator e = subproc_to_edge_.find(subproc); + result->edge = e->second; + subproc_to_edge_.erase(e); delete subproc; return true; @@ -541,11 +541,11 @@ void Builder::Cleanup() { vector active_edges = command_runner_->GetActiveEdges(); command_runner_->Abort(); - for (vector::iterator i = active_edges.begin(); - i != active_edges.end(); ++i) { - string depfile = (*i)->GetUnescapedDepfile(); - for (vector::iterator ni = (*i)->outputs_.begin(); - ni != (*i)->outputs_.end(); ++ni) { + for (vector::iterator e = active_edges.begin(); + e != active_edges.end(); ++e) { + string depfile = (*e)->GetUnescapedDepfile(); + for (vector::iterator o = (*e)->outputs_.begin(); + o != (*e)->outputs_.end(); ++o) { // Only delete this output if it was actually modified. This is // important for things like the generator where we don't want to // delete the manifest file if we can avoid it. But if the rule @@ -554,8 +554,8 @@ void Builder::Cleanup() { // mentioned in a depfile, and the command touches its depfile // but is interrupted before it touches its output file.) if (!depfile.empty() || - (*ni)->mtime() != disk_interface_->Stat((*ni)->path())) { - disk_interface_->RemoveFile((*ni)->path()); + (*o)->mtime() != disk_interface_->Stat((*o)->path())) { + disk_interface_->RemoveFile((*o)->path()); } } if (!depfile.empty()) @@ -690,9 +690,9 @@ bool Builder::StartEdge(Edge* edge, string* err) { // Create directories necessary for outputs. // XXX: this will block; do we care? - for (vector::iterator i = edge->outputs_.begin(); - i != edge->outputs_.end(); ++i) { - if (!disk_interface_->MakeDirs((*i)->path())) + for (vector::iterator o = edge->outputs_.begin(); + o != edge->outputs_.end(); ++o) { + if (!disk_interface_->MakeDirs((*o)->path())) return false; } @@ -752,14 +752,14 @@ bool Builder::FinishCommand(CommandRunner::Result* result, string* err) { if (edge->GetBindingBool("restat") && !config_.dry_run) { bool node_cleaned = false; - for (vector::iterator i = edge->outputs_.begin(); - i != edge->outputs_.end(); ++i) { - TimeStamp new_mtime = disk_interface_->Stat((*i)->path()); - if ((*i)->mtime() == new_mtime) { + for (vector::iterator o = edge->outputs_.begin(); + o != edge->outputs_.end(); ++o) { + TimeStamp new_mtime = disk_interface_->Stat((*o)->path()); + if ((*o)->mtime() == new_mtime) { // The rule command did not change the output. Propagate the clean // state through the build graph. // Note that this also applies to nonexistent outputs (mtime == 0). - plan_.CleanNode(&scan_, *i); + plan_.CleanNode(&scan_, *o); node_cleaned = true; } } diff --git a/src/graph.cc b/src/graph.cc index af7a22d..57f790c 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -112,11 +112,11 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) { // Finally, visit each output to mark off that we've visited it, and update // their dirty state if necessary. - for (vector::iterator i = edge->outputs_.begin(); - i != edge->outputs_.end(); ++i) { - (*i)->StatIfNecessary(disk_interface_); + for (vector::iterator o = edge->outputs_.begin(); + o != edge->outputs_.end(); ++o) { + (*o)->StatIfNecessary(disk_interface_); if (dirty) - (*i)->MarkDirty(); + (*o)->MarkDirty(); } // If an edge is dirty, its outputs are normally not ready. (It's @@ -132,11 +132,11 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) { bool DependencyScan::RecomputeOutputsDirty(Edge* edge, Node* most_recent_input) { - string command = edge->EvaluateCommand(true); - for (vector::iterator i = edge->outputs_.begin(); - i != edge->outputs_.end(); ++i) { - (*i)->StatIfNecessary(disk_interface_); - if (RecomputeOutputDirty(edge, most_recent_input, command, *i)) + string command = edge->EvaluateCommand(/*incl_rsp_file=*/true); + for (vector::iterator o = edge->outputs_.begin(); + o != edge->outputs_.end(); ++o) { + (*o)->StatIfNecessary(disk_interface_); + if (RecomputeOutputDirty(edge, most_recent_input, command, *o)) return true; } return false; -- cgit v0.12