-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove double decoding in unmarshalSingleValue #3018
Remove double decoding in unmarshalSingleValue #3018
Conversation
The callers of unmarshalSingleValue() always unmarshal the inputs of this function into `json.RawMessage`. These `json.RawMessage` contain a valid JSON data that can be parsed directly. Doing an Unmarshal of `json.RawMessage` into `json.RawMessage` looks confusing and not very useful. This change is mostly about the readability and code clarity. As a side note, it also improves `sjson` unmarshalling performance. name old time/op new time/op delta Array/array_all/UnmarshalJSON-8 34.6µs ± 1% 21.7µs ± 1% -37.36% (p=0.000 n=10+9) Document/all/UnmarshalJSON-8 120µs ± 0% 77µs ± 1% -36.04% (p=0.000 n=9+10) [Geo mean] 64.5µs 40.8µs -36.70% name old speed new speed delta Array/array_all/UnmarshalJSON-8 1.62MB/s ± 1% 2.58MB/s ± 1% ~ (p=0.000 n=10+9) Document/all/UnmarshalJSON-8 2.15MB/s ± 1% 3.37MB/s ± 1% +56.37% (p=0.000 n=9+10) [Geo mean] 1.87MB/s 2.95MB/s +57.97% name old alloc/op new alloc/op delta Array/array_all/UnmarshalJSON-8 41.4kB ± 0% 22.0kB ± 0% -46.92% (p=0.000 n=10+10) Document/all/UnmarshalJSON-8 117kB ± 0% 62kB ± 0% -46.89% (p=0.000 n=10+10) [Geo mean] 69.6kB 37.0kB -46.91% name old allocs/op new allocs/op delta Array/array_all/UnmarshalJSON-8 184 ± 0% 119 ± 0% -35.33% (p=0.000 n=10+10) Document/all/UnmarshalJSON-8 580 ± 0% 374 ± 0% -35.52% (p=0.000 n=10+10) [Geo mean] 327 211 -35.42%
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3018 +/- ##
==========================================
+ Coverage 72.72% 76.22% +3.50%
==========================================
Files 382 385 +3
Lines 20815 21060 +245
==========================================
+ Hits 15137 16054 +917
+ Misses 4730 4080 -650
+ Partials 948 926 -22
... and 82 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on where and how unmarshalSingleValue
is used, the changes look good to me (the callers already call checkConsumed
and provide json.RawMessage
, so no need to do it again). Nice catch!
Description
The callers of unmarshalSingleValue() always unmarshal the inputs of this function into
json.RawMessage
.These
json.RawMessage
contain valid JSON datathat can be parsed directly. Doing an Unmarshal of
json.RawMessage
intojson.RawMessage
looks confusing and not very useful.This change is mostly about readability and code clarity.
As a side note, it also improves
sjson
unmarshalling performance.Readiness checklist
task all
, and it passed.@FerretDB/core
), Labels, Project and project's Sprint fields.