From 87ae5be1895899e71103160b43b903fb8b31f132 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Thu, 9 Jun 2016 18:14:22 +0200 Subject: Constify State::RootNodes(). --- src/state.cc | 9 +++++---- 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 State::RootNodes(string* err) { +vector State::RootNodes(string* err) const { vector root_nodes; // Search for nodes with no output. - for (vector::iterator e = edges_.begin(); e != edges_.end(); ++e) { - for (vector::iterator out = (*e)->outputs_.begin(); + for (vector::const_iterator e = edges_.begin(); + e != edges_.end(); ++e) { + for (vector::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 State::RootNodes(string* err) { return root_nodes; } -vector State::DefaultNodes(string* err) { +vector 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 RootNodes(string* error); - vector DefaultNodes(string* error); + vector RootNodes(string* error) const; + vector DefaultNodes(string* error) const; /// Mapping of path -> Node. typedef ExternalStringHashMap::Type Paths; -- cgit v0.12