summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolas Despres <nicolas.despres@gmail.com>2016-06-09 16:14:22 (GMT)
committerNicolas Despres <nicolas.despres@gmail.com>2016-06-09 16:14:22 (GMT)
commit87ae5be1895899e71103160b43b903fb8b31f132 (patch)
tree9c02c733c2a53fb2f983be5d5458153985182f77 /src
parent8d65002fd5e6f2102447ab15f636cc84db3384ec (diff)
downloadNinja-87ae5be1895899e71103160b43b903fb8b31f132.zip
Ninja-87ae5be1895899e71103160b43b903fb8b31f132.tar.gz
Ninja-87ae5be1895899e71103160b43b903fb8b31f132.tar.bz2
Constify State::RootNodes().
Diffstat (limited to 'src')
-rw-r--r--src/state.cc9
-rw-r--r--src/state.h4
2 files changed, 7 insertions, 6 deletions
diff --git a/src/state.cc b/src/state.cc
index a70f211..d539e7b 100644
--- a/src/state.cc
+++ b/src/state.cc
@@ -159,11 +159,12 @@ bool State::AddDefault(StringPiece path, string* err) {
return true;
}
-vector<Node*> State::RootNodes(string* err) {
+vector<Node*> State::RootNodes(string* err) const {
vector<Node*> root_nodes;
// Search for nodes with no output.
- for (vector<Edge*>::iterator e = edges_.begin(); e != edges_.end(); ++e) {
- for (vector<Node*>::iterator out = (*e)->outputs_.begin();
+ for (vector<Edge*>::const_iterator e = edges_.begin();
+ e != edges_.end(); ++e) {
+ for (vector<Node*>::const_iterator out = (*e)->outputs_.begin();
out != (*e)->outputs_.end(); ++out) {
if ((*out)->out_edges().empty())
root_nodes.push_back(*out);
@@ -176,7 +177,7 @@ vector<Node*> State::RootNodes(string* err) {
return root_nodes;
}
-vector<Node*> State::DefaultNodes(string* err) {
+vector<Node*> State::DefaultNodes(string* err) const {
return defaults_.empty() ? RootNodes(err) : defaults_;
}
diff --git a/src/state.h b/src/state.h
index d7987ba..b530207 100644
--- a/src/state.h
+++ b/src/state.h
@@ -110,8 +110,8 @@ struct State {
/// @return the root node(s) of the graph. (Root nodes have no output edges).
/// @param error where to write the error message if somethings went wrong.
- vector<Node*> RootNodes(string* error);
- vector<Node*> DefaultNodes(string* error);
+ vector<Node*> RootNodes(string* error) const;
+ vector<Node*> DefaultNodes(string* error) const;
/// Mapping of path -> Node.
typedef ExternalStringHashMap<Node*>::Type Paths;