mirror of
https://github.com/nlohmann/json.git
synced 2026-10-23 14:28:54 +00:00
Move dump_ascii() and dump_pretty() next to dump()
Address a review comment: the two dispatchers that dump() calls now follow it directly. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+78
-78
No files matched your search
@@ -439,6 +439,45 @@ class view_serializer
|
||||
}
|
||||
|
||||
private:
|
||||
/// dump_text() with ensure_ascii, out of line: the walk without it is
|
||||
/// faster when it is not merged with this one into dump()
|
||||
NLOHMANN_VIEW_NOINLINE void dump_ascii(const node* root)
|
||||
{
|
||||
if (m_style.pretty)
|
||||
{
|
||||
if (m_style.source_numbers)
|
||||
{
|
||||
dump_text<true, true, true>(root);
|
||||
}
|
||||
else
|
||||
{
|
||||
dump_text<false, true, true>(root);
|
||||
}
|
||||
}
|
||||
else if (m_style.source_numbers)
|
||||
{
|
||||
dump_text<true, false, true>(root);
|
||||
}
|
||||
else
|
||||
{
|
||||
dump_text<false, false, true>(root);
|
||||
}
|
||||
}
|
||||
|
||||
/// dump_text() with indentation, out of line: the compact walk is faster
|
||||
/// when it is not merged with the indented ones into dump()
|
||||
NLOHMANN_VIEW_NOINLINE void dump_pretty(const node* root)
|
||||
{
|
||||
if (m_style.source_numbers)
|
||||
{
|
||||
dump_text<true, true, false>(root);
|
||||
}
|
||||
else
|
||||
{
|
||||
dump_text<false, true, false>(root);
|
||||
}
|
||||
}
|
||||
|
||||
/// a string that is not a plain string of the source (decoded, or written
|
||||
/// by an edit), without ensure_ascii: runs without characters to escape
|
||||
/// are copied. If validate is set, the string must be valid UTF-8: the
|
||||
@@ -469,45 +508,6 @@ class view_serializer
|
||||
m_out.put('"');
|
||||
}
|
||||
|
||||
/// dump_text() with indentation, out of line: the compact walk is faster
|
||||
/// when it is not merged with the indented ones into dump()
|
||||
NLOHMANN_VIEW_NOINLINE void dump_pretty(const node* root)
|
||||
{
|
||||
if (m_style.source_numbers)
|
||||
{
|
||||
dump_text<true, true, false>(root);
|
||||
}
|
||||
else
|
||||
{
|
||||
dump_text<false, true, false>(root);
|
||||
}
|
||||
}
|
||||
|
||||
/// dump_text() with ensure_ascii, out of line: the walk without it is
|
||||
/// faster when it is not merged with this one into dump()
|
||||
NLOHMANN_VIEW_NOINLINE void dump_ascii(const node* root)
|
||||
{
|
||||
if (m_style.pretty)
|
||||
{
|
||||
if (m_style.source_numbers)
|
||||
{
|
||||
dump_text<true, true, true>(root);
|
||||
}
|
||||
else
|
||||
{
|
||||
dump_text<false, true, true>(root);
|
||||
}
|
||||
}
|
||||
else if (m_style.source_numbers)
|
||||
{
|
||||
dump_text<true, false, true>(root);
|
||||
}
|
||||
else
|
||||
{
|
||||
dump_text<false, false, true>(root);
|
||||
}
|
||||
}
|
||||
|
||||
/// whether dump_text() copies a string or key from the source: one of
|
||||
/// the source, and with ensure_ascii one without bytes >= 0x7F (an overload
|
||||
/// each, so that the walk without ensure_ascii is compiled exactly as
|
||||
|
||||
Reference in new issue
Block a user