This change reuses the string length that available from 'ds', saving a strlen() call.
Signed-off-by: Andy Zhou <az...@nicira.com> --- lib/jsonrpc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index ae51b42..282f3bb 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -238,6 +238,7 @@ jsonrpc_send(struct jsonrpc *rpc, struct jsonrpc_msg *msg) { struct ofpbuf *buf; struct json *json; + struct ds ds = DS_EMPTY_INITIALIZER; size_t length; char *s; @@ -249,8 +250,9 @@ jsonrpc_send(struct jsonrpc *rpc, struct jsonrpc_msg *msg) jsonrpc_log_msg(rpc, "send", msg); json = jsonrpc_msg_to_json(msg); - s = json_to_string(json, 0); - length = strlen(s); + json_to_ds(json, 0, &ds); + length = ds.length; + s = ds_steal_cstr(&ds); json_destroy(json); buf = xmalloc(sizeof *buf); -- 1.9.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev