summaryrefslogtreecommitdiffstats
path: root/src/state.cc
diff options
context:
space:
mode:
authorRobert Iannucci <robbie@rail.com>2013-03-18 17:36:23 (GMT)
committerRobert Iannucci <robbie@rail.com>2013-03-18 17:36:23 (GMT)
commit8e70a53058a74d3582c609fd9f7c133dae7387b4 (patch)
tree941b9a9643cc3fec5a8c86e341059f40f2a9847e /src/state.cc
parent72b3dae6aa936e9eabf4c22e5602c572a9756cbe (diff)
downloadNinja-8e70a53058a74d3582c609fd9f7c133dae7387b4.zip
Ninja-8e70a53058a74d3582c609fd9f7c133dae7387b4.tar.gz
Ninja-8e70a53058a74d3582c609fd9f7c133dae7387b4.tar.bz2
Fix Pool to use a set internally
Diffstat (limited to 'src/state.cc')
-rw-r--r--src/state.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/state.cc b/src/state.cc
index b5d2622..cd43e0d 100644
--- a/src/state.cc
+++ b/src/state.cc
@@ -35,23 +35,25 @@ void Pool::EdgeFinished(const Edge& edge) {
void Pool::DelayEdge(Edge* edge) {
assert(depth_ != 0);
- delayed_.push_back(edge);
+ delayed_.insert(edge);
}
void Pool::RetrieveReadyEdges(set<Edge*>* ready_queue) {
- while (!delayed_.empty()) {
- Edge* edge = delayed_.front();
+ set<Edge*>::iterator it = delayed_.begin();
+ while (it != delayed_.end()) {
+ Edge* edge = *it;
if (current_use_ + edge->weight() > depth_)
break;
- delayed_.pop_front();
ready_queue->insert(edge);
EdgeScheduled(*edge);
+ ++it;
}
+ delayed_.erase(delayed_.begin(), it);
}
void Pool::Dump() const {
printf("%s (%d/%d) ->\n", name_.c_str(), current_use_, depth_);
- for (deque<Edge*>::const_iterator it = delayed_.begin();
+ for (set<Edge*>::const_iterator it = delayed_.begin();
it != delayed_.end(); ++it)
{
printf("\t");
@@ -59,6 +61,13 @@ void Pool::Dump() const {
}
}
+bool Pool::WeightedEdgeCmp(const Edge* a, const Edge* b) {
+ if (!a) return b;
+ if (!b) return false;
+ int weight_diff = a->weight() - b->weight();
+ return ((weight_diff < 0) || (weight_diff == 0 && a < b));
+}
+
Pool State::kDefaultPool("", 0);
const Rule State::kPhonyRule("phony");