diff options
author | Nico Weber <nicolasweber@gmx.de> | 2016-06-11 00:58:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-11 00:58:40 (GMT) |
commit | 5739c144354c826b57042ad0968680c272a95856 (patch) | |
tree | 9c02c733c2a53fb2f983be5d5458153985182f77 /src | |
parent | 8d65002fd5e6f2102447ab15f636cc84db3384ec (diff) | |
parent | 87ae5be1895899e71103160b43b903fb8b31f132 (diff) | |
download | Ninja-5739c144354c826b57042ad0968680c272a95856.zip Ninja-5739c144354c826b57042ad0968680c272a95856.tar.gz Ninja-5739c144354c826b57042ad0968680c272a95856.tar.bz2 |
Merge pull request #1164 from nicolasdespres/const_rootnodes
Constify State::RootNodes().
Diffstat (limited to 'src')
-rw-r--r-- | src/state.cc | 9 | ||||
-rw-r--r-- | src/state.h | 4 |
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; |