3 ms·
Nice project! One little remark: I see you're being slightly lazy and using JSON to save some value conversion work. One problem is that this is not very good f
by ivan4th 11y ago
Nice project! One little remark: I see you're being slightly lazy and using JSON to save some value conversion work. One problem is that this is not very good from a performance standpoint. The other, more serious issue is that your code will not work if someone tries to pass around a data structure containing NaN value, like []float64{math.NaN()} Got bitten by this problem, had to fix it: https://github.com/contactless/wb-rules/commit/067ff7564f16aba0d21ff7c2761839dd15f97ac9 https://github.com/contactless/wb-rules/commit/067ff7564f16a...
- mcuadros 11y agoTrue in some cases I fold back to JSON: https://github.com/mcuadros/go-candyjs/blob/master/base.go#L272 https://github.com/mcuadros/go-candyjs/blob/master/base.go#L... But the main goal of the project is be fully transparent more than the performance. At the very beginning I was making every case by hand but this is a endless work: https://github.com/mcuadros/go-candyjs/blob/54c8beb723aa8b1b21f2d5864b0809f326d9a85d/engine/duktape/register.go#L142-L167 https://github.com/mcuadros/go-candyjs/blob/54c8beb723aa8b1b... I will take a closer look to the NaN issue and also a closer look to your code. BTW I made a PR to go-duktape based on you fork: https://github.com/olebedev/go-duktape/commit/65f0be48ece4f6405c93c3b5312fab074320bfef https://github.com/olebedev/go-duktape/commit/65f0be48ece4f6...
- ivan4th 11y agoUnfortunately NaN behavior seems to be hard-wired in encoding/json code. The proper way to fix it is perhaps taking encoding/json sources and converting marshalling/unmarshalling code to use go-duktape Push/To/etc. functions instead of JSON writing/parsing. That's indeed a sizable amount of work, though. As of integrating (some of) changes from my fork to the go-duktape mainline, thanks a lot! Didn't get around to do it myself.