mirror of
https://github.com/nlohmann/json.git
synced 2026-09-05 15:57:58 +00:00
Spell out the move rationale at every handle_value(std::move) site
The comment explaining why the value is moved sat only on json_sax_dom_parser::string(), and the callback parser's string() pointed at it with "see json_sax_dom_parser::string()". That reference cannot be searched for - the function is declared as `bool string(string_t& val)` inside the class, so the qualified name appears nowhere - and the two binary() overloads, which have always moved, carried no explanation at all. Put the same comment on all four sites and name json_sax, which is greppable, instead of a member that is not. Comment-only; no generated code changes. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -222,14 +222,16 @@ class json_sax_dom_parser
|
||||
|
||||
bool string(string_t& val)
|
||||
{
|
||||
// the interface allows moving the value (see json_sax::string), which
|
||||
// hands the lexer's buffer to the new value instead of copying it
|
||||
// json_sax documents that the passed value may be moved from,
|
||||
// so hand the buffer over instead of copying it
|
||||
handle_value(std::move(val));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool binary(binary_t& val)
|
||||
{
|
||||
// json_sax documents that the passed value may be moved from,
|
||||
// so hand the buffer over instead of copying it
|
||||
handle_value(std::move(val));
|
||||
return true;
|
||||
}
|
||||
@@ -534,13 +536,16 @@ class json_sax_dom_callback_parser
|
||||
|
||||
bool string(string_t& val)
|
||||
{
|
||||
// see json_sax_dom_parser::string()
|
||||
// json_sax documents that the passed value may be moved from,
|
||||
// so hand the buffer over instead of copying it
|
||||
handle_value(std::move(val));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool binary(binary_t& val)
|
||||
{
|
||||
// json_sax documents that the passed value may be moved from,
|
||||
// so hand the buffer over instead of copying it
|
||||
handle_value(std::move(val));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10804,14 +10804,16 @@ class json_sax_dom_parser
|
||||
|
||||
bool string(string_t& val)
|
||||
{
|
||||
// the interface allows moving the value (see json_sax::string), which
|
||||
// hands the lexer's buffer to the new value instead of copying it
|
||||
// json_sax documents that the passed value may be moved from,
|
||||
// so hand the buffer over instead of copying it
|
||||
handle_value(std::move(val));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool binary(binary_t& val)
|
||||
{
|
||||
// json_sax documents that the passed value may be moved from,
|
||||
// so hand the buffer over instead of copying it
|
||||
handle_value(std::move(val));
|
||||
return true;
|
||||
}
|
||||
@@ -11116,13 +11118,16 @@ class json_sax_dom_callback_parser
|
||||
|
||||
bool string(string_t& val)
|
||||
{
|
||||
// see json_sax_dom_parser::string()
|
||||
// json_sax documents that the passed value may be moved from,
|
||||
// so hand the buffer over instead of copying it
|
||||
handle_value(std::move(val));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool binary(binary_t& val)
|
||||
{
|
||||
// json_sax documents that the passed value may be moved from,
|
||||
// so hand the buffer over instead of copying it
|
||||
handle_value(std::move(val));
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user