Commit ec15abbf authored by Akim Demaille's avatar Akim Demaille
Browse files

style: add a few const and auto

parent 5eec90be
......@@ -162,8 +162,8 @@ namespace vcsn
void
add_entry(string_t src, string_t dst, string_t entry) override final
{
auto s = state_(src);
auto d = state_(dst);
const auto s = state_(src);
const auto d = state_(dst);
require(s != res_->pre() || d != res_->post(),
"edit_automaton: invalid transition from pre to post: ",
src, " -> ", dst, " (", entry, ")");
......
......@@ -87,7 +87,7 @@ namespace vcsn
aut_proper_t operator()()
{
auto proper_ctx = make_proper_context(aut_->context());
const auto proper_ctx = make_proper_context(aut_->context());
auto res = make_shared_ptr<aut_proper_t>(proper_ctx);
in_situ_remover();
......@@ -193,15 +193,15 @@ namespace vcsn
{
// Iterate on a copy, as we remove these transitions in the
// loop.
auto transitions = make_vector(in(aut_, s, empty_word_));
const auto transitions = make_vector(in(aut_, s, empty_word_));
// The star of the weight of the loop on 's' (1 if no loop).
weight_t star = ws_.one();
using state_weight_t = std::pair<state_t, weight_t>;
std::vector<state_weight_t> closure;
auto closure = std::vector<state_weight_t>{};
for (auto t : transitions)
{
weight_t weight = aut_->weight_of(t);
state_t src = aut_->src_of(t);
const weight_t weight = aut_->weight_of(t);
const state_t src = aut_->src_of(t);
if (src == s) //loop
star = ws_.star(weight);
else
......@@ -229,11 +229,11 @@ namespace vcsn
// "Blowing": For each transition (or terminal arrow)
// outgoing from (s), the weight is multiplied by
// (star).
weight_t blow = ws_.mul(star, aut_->weight_of(t));
const weight_t blow = ws_.mul(star, aut_->weight_of(t));
aut_->set_weight(t, blow);
label_t label = aut_->label_of(t);
state_t dst = aut_->dst_of(t);
const label_t label = aut_->label_of(t);
const state_t dst = aut_->dst_of(t);
for (auto pair: closure)
{
state_t src = pair.first;
......
......@@ -1256,7 +1256,7 @@ namespace vcsn
boost::optional<label_t>
conv_label(std::istream& i, bool weighted, const char sep = '+') const
{
int peek = i.peek();
const auto peek = i.peek();
assert(peek != '[');
if (peek == '\\')
{
......@@ -1296,7 +1296,7 @@ namespace vcsn
}
else
{
auto pos = i.tellg();
const auto pos = i.tellg();
res = labelset()->conv(i);
// In law_char, when reading the monomial `a|b` (yes, `|` is
// not escaped), we looped for ever: the `a` was read by
......@@ -1363,9 +1363,8 @@ namespace vcsn
/// Read a polynomial from a stream.
///
/// Somewhat more general than a mere inverse of `print`,
/// in particular `a+a` is properly understood as `<2>a` in `lal,
/// z`.
/// More general than a mere inverse of `print`, in particular
/// `a+a` is properly understood as `<2>a` in `lal, z`.
///
/// \param i the stream to parse.
/// \param sep the separator between monomials.
......@@ -1381,8 +1380,8 @@ namespace vcsn
{
// Possibly a weight in braces.
SKIP_SPACES();
bool weighted = i.peek() == langle;
weight_t w = conv_weight(i);
const bool weighted = i.peek() == langle;
const weight_t w = conv_weight(i);
SKIP_SPACES();
// Possibly, a label.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment