ducaale / xh

Friendly and fast tool for sending HTTP requests
MIT License
4.96k stars 90 forks source link

Use serde-transcode to optimize JSON formatting #362

Closed blyxxyz closed 2 months ago

blyxxyz commented 2 months ago

Followup to #361 (which I meant to look at but forgot).

Instead of parsing the JSON input into a serde::Value we can use serde-transcode to serialize straight from the input to the output. On an articial very large JSON file I use for testing this ends up five times faster. (Maybe slightly faster than jsonxf was?) I got this trick from jsonxf's serde benchmark.

(The rest of the PR looked great. Thanks, @zuisong!)

I also included a tiny theoretical bugfix for decompression that I wrote a while ago but didn't think was worth a PR, see the explanation in 398d5673800d06c06b39b91f24a097864b83679a