Stats printing: Move emitter -> manual cutoff point.

This makes it so that the "general" portion of the stats code is completely
agnostic to emitter type.
This commit is contained in:
David Goldblatt 2018-03-01 19:01:05 -08:00 committed by David Goldblatt
parent ec31d476ff
commit 0d20eda127

View File

@ -668,15 +668,7 @@ stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque,
}
static void
stats_general_print(emitter_t *emitter, bool more) {
/*
* These should eventually be deleted; they are useful in converting
* from manual to emitter-based stats output, though.
*/
void (*write_cb)(void *, const char *) = emitter->write_cb;
void *cbopaque = emitter->cbopaque;
bool json = (emitter->output == emitter_output_json);
stats_general_print(emitter_t *emitter) {
const char *cpv;
bool bv, bv2;
unsigned uv;
@ -911,14 +903,6 @@ stats_general_print(emitter_t *emitter, bool more) {
}
emitter_json_dict_end(emitter); /* Close "arenas" */
if (json) {
if (more) {
malloc_cprintf(write_cb, cbopaque, ",\n");
} else {
malloc_cprintf(write_cb, cbopaque, "\n");
}
}
}
static void
@ -1208,7 +1192,16 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
emitter_json_dict_begin(&emitter, "jemalloc");
if (general) {
stats_general_print(&emitter, config_stats);
stats_general_print(&emitter);
if (json) {
if (config_stats) {
malloc_cprintf(write_cb, cbopaque, ",");
}
}
}
if (json) {
malloc_cprintf(write_cb, cbopaque, "\n");
}
if (config_stats) {
stats_print_helper(write_cb, cbopaque, json, merged, destroyed,