-
Notifications
You must be signed in to change notification settings - Fork 319
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
Optimize encoding performance in Erlang #150
base: master
Are you sure you want to change the base?
Conversation
@davisp ping :) would you consider including this optimization? Idea is to avoid expensive operation of changing %{
1 => "val",
2 => "val"
} to %{
"1" => "val",
"2" => "val"
} before passing it to jiffy encoder. 😈 Bad excuse is that JS JSON.stringify allows it :) :P :P If yes - I'll rebase it on current master and also update docs. |
Python allows it as well so I'm not against it. |
c_src/encoder.c
Outdated
goto done; | ||
} | ||
} | ||
else { |
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.
Style nit: This "else {" should be moved up to the previous line.
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.
ok, thanks, I'll tidy up and resubmit PR
Ok, did small fixes. Do you want another branch + everything squashed in one commit? |
Optimize encoding performance in Erlang davisp#150
Just tried this and for me it fails for ** exception throw: {error,{invalid_object_member_key,1}} |
I'm not sure you are using version from this branch. I think it is not merged yet into main tree :( |
Would be nice to merge this |
Right now jiffy requires keys in maps or keyword tuples to be strings to be successfully encoded.
If existing keys in map are integers - whole map should be recreated with keys converted to integers - which is huge overhead in terms of CPU/RAM usage.
This patch allows integer to be serialized into JSON as map's key as well.
May be it should be enabled only when some option is passed to encoder.