Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/json_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ std::string EscapeJsonChars(const std::string& str) {
}

std::string Reindent(const std::string& str, int indent_depth) {
std::string indent;
for (int i = 0; i < indent_depth; i++) indent += ' ';

if (indent_depth <= 0) return str;
const std::string indent(indent_depth, ' ');
std::string out;
std::string::size_type pos = 0;
do {
for (;;) {
std::string::size_type prev_pos = pos;
pos = str.find('\n', pos);

Expand All @@ -59,7 +58,7 @@ std::string Reindent(const std::string& str, int indent_depth) {
pos++;
out.append(str, prev_pos, pos - prev_pos);
}
} while (true);
}

return out;
}
Expand Down