mirror of
https://github.com/nlohmann/json.git
synced 2026-09-11 18: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)
|
bool string(string_t& val)
|
||||||
{
|
{
|
||||||
// the interface allows moving the value (see json_sax::string), which
|
// json_sax documents that the passed value may be moved from,
|
||||||
// hands the lexer's buffer to the new value instead of copying it
|
// so hand the buffer over instead of copying it
|
||||||
handle_value(std::move(val));
|
handle_value(std::move(val));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool binary(binary_t& val)
|
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));
|
handle_value(std::move(val));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -534,13 +536,16 @@ class json_sax_dom_callback_parser
|
|||||||
|
|
||||||
bool string(string_t& val)
|
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));
|
handle_value(std::move(val));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool binary(binary_t& val)
|
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));
|
handle_value(std::move(val));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10935,14 +10935,16 @@ class json_sax_dom_parser
|
|||||||
|
|
||||||
bool string(string_t& val)
|
bool string(string_t& val)
|
||||||
{
|
{
|
||||||
// the interface allows moving the value (see json_sax::string), which
|
// json_sax documents that the passed value may be moved from,
|
||||||
// hands the lexer's buffer to the new value instead of copying it
|
// so hand the buffer over instead of copying it
|
||||||
handle_value(std::move(val));
|
handle_value(std::move(val));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool binary(binary_t& val)
|
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));
|
handle_value(std::move(val));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -11247,13 +11249,16 @@ class json_sax_dom_callback_parser
|
|||||||
|
|
||||||
bool string(string_t& val)
|
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));
|
handle_value(std::move(val));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool binary(binary_t& val)
|
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));
|
handle_value(std::move(val));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user