Commit 3dde66ddcd6ad38a90bf46c4017c87f9a8656c0e

Authored by m-holger
Committed by Jay Berkenbilt
1 parent dfa7d414

Refactor JSON::writeNext

include/qpdf/JSON.hh
@@ -338,7 +338,6 @@ class JSON @@ -338,7 +338,6 @@ class JSON
338 static std::string encode_string(std::string const& utf8); 338 static std::string encode_string(std::string const& utf8);
339 static void 339 static void
340 writeClose(Pipeline* p, bool first, size_t depth, char const* delimeter); 340 writeClose(Pipeline* p, bool first, size_t depth, char const* delimeter);
341 - static void writeIndent(Pipeline* p, size_t depth);  
342 341
343 struct JSON_value 342 struct JSON_value
344 { 343 {
libqpdf/JSON.cc
@@ -42,23 +42,18 @@ JSON::writeClose(Pipeline* p, bool first, size_t depth, char const* delimiter) @@ -42,23 +42,18 @@ JSON::writeClose(Pipeline* p, bool first, size_t depth, char const* delimiter)
42 } 42 }
43 43
44 void 44 void
45 -JSON::writeIndent(Pipeline* p, size_t depth)  
46 -{  
47 - for (size_t i = 0; i < depth; ++i) {  
48 - *p << " ";  
49 - }  
50 -}  
51 -  
52 -void  
53 JSON::writeNext(Pipeline* p, bool& first, size_t depth) 45 JSON::writeNext(Pipeline* p, bool& first, size_t depth)
54 { 46 {
55 if (first) { 47 if (first) {
56 first = false; 48 first = false;
  49 + std::string s{"\n"};
  50 + s.append(2 * depth, ' ');
  51 + *p << s;
57 } else { 52 } else {
58 - *p << ","; 53 + std::string s{",\n"};
  54 + s.append(2 * depth, ' ');
  55 + *p << s;
59 } 56 }
60 - *p << "\n";  
61 - writeIndent(p, depth);  
62 } 57 }
63 58
64 void 59 void