Skip to content

Commit

Permalink
Small optimization for writing .cali strings
Browse files Browse the repository at this point in the history
  • Loading branch information
daboehme committed Oct 31, 2024
1 parent 6ba08bf commit af4157d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/common/util/format_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ inline std::ostream& write_cali_esc_string(std::ostream& os, const char* str, st
for (size_t i = 0; i < size; ++i) {
const char c = str[i];

if (c == '\n') { // handle newline in string
os.put('\\');
os.put('n');
}
if (c < 0x20) // skip control characters
if (c < 0x20) {
if (c == '\n') { // handle newline in string
os.put('\\');
os.put('n');
}
// skip control characters
continue;
}
if (c == '\\' || c == ',' || c == '=')
os.put('\\');

Expand Down

0 comments on commit af4157d

Please sign in to comment.