2
0
mirror of https://github.com/boostorg/spirit.git synced 2026-01-19 04:42:11 +00:00

ts_real_policies: Parse directly into output parameter

There is no need to initialize accumulator with zero value before the first
call to `parse`, and to use a temporary.
This commit is contained in:
Nikita Kniazev
2018-03-10 19:22:28 +03:00
parent dc9e23e9f5
commit 02c3c30077
3 changed files with 3 additions and 9 deletions

View File

@@ -157,7 +157,7 @@ struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
// Thousands separated numbers
template <typename Iterator, typename Accumulator>
static bool
parse_n(Iterator& first, Iterator const& last, Accumulator& attr)
parse_n(Iterator& first, Iterator const& last, Accumulator& result)
{
using boost::spirit::qi::uint_parser;
namespace qi = boost::spirit::qi;
@@ -165,7 +165,6 @@ struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
uint_parser<unsigned, 10, 1, 3> uint3;
uint_parser<unsigned, 10, 3, 3> uint3_3;
Accumulator result = 0;
if (parse(first, last, uint3, result))
{
Accumulator n;
@@ -177,7 +176,6 @@ struct ts_real_policies : boost::spirit::qi::ureal_policies<T>
first = iter;
}
attr = result;
return true;
}
return false;