summaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2023-01-28 12:15:27 +0100
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2023-01-28 20:49:32 +0100
commit3dde66ddcd6ad38a90bf46c4017c87f9a8656c0e (patch)
tree4c2abd503a0f58a701e156a6d3306237b1d18d97 /libqpdf
parentdfa7d414f56d08b68cbf72023c9cceb0c9e5a6d9 (diff)
downloadqpdf-3dde66ddcd6ad38a90bf46c4017c87f9a8656c0e.tar.zst
Refactor JSON::writeNext
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/JSON.cc17
1 files changed, 6 insertions, 11 deletions
diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc
index 7bdf01d4..fd76e628 100644
--- a/libqpdf/JSON.cc
+++ b/libqpdf/JSON.cc
@@ -42,23 +42,18 @@ JSON::writeClose(Pipeline* p, bool first, size_t depth, char const* delimiter)
}
void
-JSON::writeIndent(Pipeline* p, size_t depth)
-{
- for (size_t i = 0; i < depth; ++i) {
- *p << " ";
- }
-}
-
-void
JSON::writeNext(Pipeline* p, bool& first, size_t depth)
{
if (first) {
first = false;
+ std::string s{"\n"};
+ s.append(2 * depth, ' ');
+ *p << s;
} else {
- *p << ",";
+ std::string s{",\n"};
+ s.append(2 * depth, ' ');
+ *p << s;
}
- *p << "\n";
- writeIndent(p, depth);
}
void