From 4811024518201dfea57437a0eeef4c62820906c9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 8 Apr 2019 19:28:44 +0930 Subject: [PATCH] lightingd: optimize json_add_short_channel_id a little. MCP results from 5 runs, min-max(mean +/- stddev): store_load_msec:32825-36365(34615.6+/-1.1e+03) vsz_kb:2637488 store_rewrite_sec:35.150000-36.200000(35.59+/-0.4) listnodes_sec:0.590000-0.710000(0.682+/-0.046) listchannels_sec:28.650000-31.080000(29.966+/-0.81) routing_sec:29.980000-33.100000(31.284+/-1.5) peer_write_all_sec:49.020000-52.890000(50.376+/-1.5) MCP notable changes from previous patch (>1 stddev): -store_rewrite_sec:35.790000-37.500000(36.6375+/-0.63) +store_rewrite_sec:35.150000-36.200000(35.59+/-0.4) -listchannels_sec:34.600000-36.340000(35.36+/-0.77) +listchannels_sec:28.650000-31.080000(29.966+/-0.81) Signed-off-by: Rusty Russell --- lightningd/json.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lightningd/json.c b/lightningd/json.c index f11069e53..114c44fe3 100644 --- a/lightningd/json.c +++ b/lightningd/json.c @@ -110,10 +110,12 @@ struct command_result *param_pubkey(struct command *cmd, const char *name, void json_add_short_channel_id(struct json_stream *response, const char *fieldname, - const struct short_channel_id *id) + const struct short_channel_id *scid) { - json_add_string(response, fieldname, - type_to_string(response, struct short_channel_id, id)); + json_add_member(response, fieldname, "\"%dx%dx%d\"", + short_channel_id_blocknum(scid), + short_channel_id_txnum(scid), + short_channel_id_outnum(scid)); } struct command_result *param_short_channel_id(struct command *cmd,