From feded888dd7faeff3a6afaf07090f1b01383083b Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 29 Aug 2020 10:32:12 +1000 Subject: [PATCH] Have jsonfindptrs not flush stdout after each line On a mid-range x86_64 laptop, processing the 181 MiB citylots.json file from github.com/zemirco/sf-city-lots-json: $ time gen/bin/example-jsonfindptrs < citylots.json > /dev/null Before this commit: real 0m21.104s After: real 0m9.774s Ratio: 2.16x --- example/jsonfindptrs/jsonfindptrs.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/jsonfindptrs/jsonfindptrs.cc b/example/jsonfindptrs/jsonfindptrs.cc index 7996b096..4da2a18f 100644 --- a/example/jsonfindptrs/jsonfindptrs.cc +++ b/example/jsonfindptrs/jsonfindptrs.cc @@ -350,7 +350,7 @@ escape_needed: std::string // print_json_pointers(JsonThing& jt, std::string s, uint32_t depth) { - std::cout << s << std::endl; + std::cout << s << '\n'; if (depth++ >= g_flags.max_output_depth) { return ""; } @@ -534,7 +534,7 @@ compute_exit_code(std::string status_msg) { if (status_msg.empty()) { return 0; } - std::cerr << status_msg << std::endl; + std::cerr << status_msg << '\n'; // Return an exit code of 1 for regular (forseen) errors, e.g. badly // formatted or unsupported input. //