From 0d20eda127c4f35c16cfffad15857d3b286166ba Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Thu, 1 Mar 2018 19:01:05 -0800 Subject: [PATCH] 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. --- src/stats.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/stats.c b/src/stats.c index ca843e2d..583c1316 100644 --- a/src/stats.c +++ b/src/stats.c @@ -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,