Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0f73a43

Browse files
authoredOct 20, 2022
Merge branch 'master' into avi/clean-up-gefield-tfuncs
2 parents 11c139f + 0d52506 commit 0f73a43

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed
 

‎src/gc-heap-snapshot.cpp

+23-23
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,26 @@ using llvm::StringRef;
2424
// https://stackoverflow.com/a/33799784/751061
2525
void print_str_escape_json(ios_t *stream, StringRef s)
2626
{
27-
ios_printf(stream, "\"");
27+
ios_putc('"', stream);
2828
for (auto c = s.begin(); c != s.end(); c++) {
2929
switch (*c) {
30-
case '"': ios_printf(stream, "\\\""); break;
31-
case '\\': ios_printf(stream, "\\\\"); break;
32-
case '\b': ios_printf(stream, "\\b"); break;
33-
case '\f': ios_printf(stream, "\\f"); break;
34-
case '\n': ios_printf(stream, "\\n"); break;
35-
case '\r': ios_printf(stream, "\\r"); break;
36-
case '\t': ios_printf(stream, "\\t"); break;
30+
case '"': ios_write(stream, "\\\"", 2); break;
31+
case '\\': ios_write(stream, "\\\\", 2); break;
32+
case '\b': ios_write(stream, "\\b", 2); break;
33+
case '\f': ios_write(stream, "\\f", 2); break;
34+
case '\n': ios_write(stream, "\\n", 2); break;
35+
case '\r': ios_write(stream, "\\r", 2); break;
36+
case '\t': ios_write(stream, "\\t", 2); break;
3737
default:
38-
if ('\x00' <= *c && *c <= '\x1f') {
38+
if (('\x00' <= *c) & (*c <= '\x1f')) {
3939
ios_printf(stream, "\\u%04x", (int)*c);
4040
}
4141
else {
42-
ios_printf(stream, "%c", *c);
42+
ios_putc(*c, stream);
4343
}
4444
}
4545
}
46-
ios_printf(stream, "\"");
46+
ios_putc('"', stream);
4747
}
4848

4949

@@ -469,14 +469,14 @@ void serialize_heap_snapshot(ios_t *stream, HeapSnapshot &snapshot, char all_one
469469
ios_printf(stream, ",");
470470
}
471471
// ["type","name","id","self_size","edge_count","trace_node_id","detachedness"]
472-
ios_printf(stream, "%zu", from_node.type);
473-
ios_printf(stream, ",%zu", from_node.name);
474-
ios_printf(stream, ",%zu", from_node.id);
475-
ios_printf(stream, ",%zu", all_one ? (size_t)1 : from_node.self_size);
476-
ios_printf(stream, ",%zu", from_node.edges.size());
477-
ios_printf(stream, ",%zu", from_node.trace_node_id);
478-
ios_printf(stream, ",%d", from_node.detachedness);
479-
ios_printf(stream, "\n");
472+
ios_printf(stream, "%zu,%zu,%zu,%zu,%zu,%zu,%d\n",
473+
from_node.type,
474+
from_node.name,
475+
from_node.id,
476+
all_one ? (size_t)1 : from_node.self_size,
477+
from_node.edges.size(),
478+
from_node.trace_node_id,
479+
from_node.detachedness);
480480
}
481481
ios_printf(stream, "],\n");
482482

@@ -490,10 +490,10 @@ void serialize_heap_snapshot(ios_t *stream, HeapSnapshot &snapshot, char all_one
490490
else {
491491
ios_printf(stream, ",");
492492
}
493-
ios_printf(stream, "%zu", edge.type);
494-
ios_printf(stream, ",%zu", edge.name_or_index);
495-
ios_printf(stream, ",%zu", edge.to_node * k_node_number_of_fields);
496-
ios_printf(stream, "\n");
493+
ios_printf(stream, "%zu,%zu,%zu\n",
494+
edge.type,
495+
edge.name_or_index,
496+
edge.to_node * k_node_number_of_fields);
497497
}
498498
}
499499
ios_printf(stream, "],\n"); // end "edges"

0 commit comments

Comments
 (0)
Please sign in to comment.