Optimize encoding performance in Erlang#150
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.
Style nit: This "else {" should be moved up to the previous line.
There was a problem hiding this comment.
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.