| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 449d9ec commit e07c1c2
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,12 +41,11 @@ std::string EscapeJsonChars(const std::string& str) { | |||
| 41 | 41 | } | |
| 42 | 42 | ||
| 43 | 43 | std::string Reindent(const std::string& str, int indent_depth) { | |
| 44 | - std::string indent; | ||
| 45 | - for (int i = 0; i < indent_depth; i++) indent += ' '; | ||
| 46 | - | ||
| 44 | + if (indent_depth <= 0) return str; | ||
| 45 | + const std::string indent(indent_depth, ' '); | ||
| 47 | 46 | std::string out; | |
| 48 | 47 | std::string::size_type pos = 0; | |
| 49 | - do { | ||
| 48 | + for (;;) { | ||
| 50 | 49 | std::string::size_type prev_pos = pos; | |
| 51 | 50 | pos = str.find('\n', pos); | |
| 52 | 51 | ||
@@ -59,7 +58,7 @@ std::string Reindent(const std::string& str, int indent_depth) { | |||
| 59 | 58 | pos++; | |
| 60 | 59 | out.append(str, prev_pos, pos - prev_pos); | |
| 61 | 60 | } | |
| 62 | - } while (true); | ||
| 61 | + } | ||
| 63 | 62 | ||
| 64 | 63 | return out; | |
| 65 | 64 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments