Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Optimize InefficientlyConvertToJS (#820)
Browse files Browse the repository at this point in the history
* Optmimize jsutil.InefficientlyConvertToJS

* Add missing build tag

* Update go.mod and go.sum
  • Loading branch information
albrow authored Jun 10, 2020
1 parent 4a026b9 commit c593d51
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 59 deletions.
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ require (
github.com/cespare/cp v1.1.1 // indirect
github.com/chromedp/cdproto v0.0.0-20190827000638-b5ac1e37ce90
github.com/chromedp/chromedp v0.4.0
github.com/coocood/freecache v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set v1.7.1 // indirect
github.com/edsrzf/mmap-go v1.0.0 // indirect
Expand Down Expand Up @@ -62,17 +61,14 @@ require (
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/multiformats/go-multiaddr v0.2.1
github.com/multiformats/go-multiaddr-dns v0.2.0
github.com/ocdogan/rbt v0.0.0-20160425054511-de6e2b48be33
github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709 // indirect
github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709
github.com/plaid/go-envvar v1.1.0
github.com/posener/complete v1.2.3 // indirect
github.com/prometheus/tsdb v0.10.0 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/status-im/keycard-go v0.0.0-20190424133014-d95853db0f48 // indirect
github.com/stretchr/testify v1.4.0
github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d
github.com/tyler-smith/go-bip39 v1.0.2 // indirect
github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190809123943-df4f5c81cb3b // indirect
Expand Down
46 changes: 1 addition & 45 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,37 +1,10 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/0xProject/go-ethereum v1.8.7 h1:pEVtlJueWP0GRypBlcGeTF17/QHErcLVa/+BEN8XM64=
github.com/0xProject/go-ethereum v1.8.8-0.20200121231321-1510563ddd1f h1:3V/XMVlgBlSh+Q1G0kg8e4dEh3UxsTpce9Ix1dDyRiU=
github.com/0xProject/go-ethereum v1.8.8-0.20200121231321-1510563ddd1f/go.mod h1:GCj8W8G7wxclyZu5dgA4vru0iUU4DK6pUE/FSPRd4Rg=
github.com/0xProject/go-ethereum v1.8.8-0.20200528180959-6d9fc754ff10 h1:JTD0bgPcURoCDc/bYcIzTYA7fy0w1vm9RNWWZD2HAn4=
github.com/0xProject/go-ethereum v1.8.8-0.20200528180959-6d9fc754ff10/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw=
github.com/0xProject/go-ethereum v1.8.8-0.20200529225138-6a74e8575db2 h1:Hq3vR6mZDQM8cg4iOUKkL/v9NOwmzJRsRVWLCNc8B/E=
github.com/0xProject/go-ethereum v1.8.8-0.20200529225138-6a74e8575db2/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw=
github.com/0xProject/go-ethereum v1.8.8-0.20200530012416-219be151393c h1:iHK8paNWmvSRNcKo+CjD6eWWQgbItt61RsIauBBx+Lg=
github.com/0xProject/go-ethereum v1.8.8-0.20200530012416-219be151393c/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw=
github.com/0xProject/go-ethereum v1.8.8-0.20200601215128-bcb6fe70d7c6 h1:rUZCgSjwfr1vkyqySd9uQjNprSLrIpl+dHZdmi232h8=
github.com/0xProject/go-ethereum v1.8.8-0.20200601215128-bcb6fe70d7c6/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw=
github.com/0xProject/go-ethereum v1.8.8-0.20200602013744-00dbb5f71e53 h1:E2waVaHqyGez4HZBiNVi8J9+fdhg0kL/WHnjpmX1/lw=
github.com/0xProject/go-ethereum v1.8.8-0.20200602013744-00dbb5f71e53/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw=
github.com/0xProject/go-ethereum v1.8.8-0.20200603163540-b12a73c53a34 h1:NVzgOsQO0wMjMcG0QEcaJDzG8KoypR3RXARxjUBmbvA=
github.com/0xProject/go-ethereum v1.8.8-0.20200603163540-b12a73c53a34/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw=
github.com/0xProject/go-ethereum v1.8.8-0.20200603221106-9eb281b27e51 h1:Fm4Rpec8mRuC8LwFlC75KT2kgZEF9JUhngdtGoEP2/Y=
github.com/0xProject/go-ethereum v1.8.8-0.20200603221106-9eb281b27e51/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw=
github.com/0xProject/go-ethereum v1.8.8-0.20200603225022-cb1f52043425 h1:BFs4B5VoJWA0PLH9DrtTvGDWqbg1thtfi6WSKQsUazg=
github.com/0xProject/go-ethereum v1.8.8-0.20200603225022-cb1f52043425/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw=
github.com/0xProject/go-libp2p-pubsub v0.1.1-0.20200228234556-aaa0317e068a h1:OHjKy7tLiqETUbEzF2UmqaF8eUTjHqmJM2sP79dguJs=
github.com/0xProject/go-libp2p-pubsub v0.1.1-0.20200228234556-aaa0317e068a/go.mod h1:R4R0kH/6p2vu8O9xsue0HNSjEuXMEPBgg4h3nVDI15o=
github.com/0xProject/go-ws-transport v0.1.1-0.20200201000210-2db3396fec39 h1:zMth0Fw7e4MWjaNoN+lKzwdvqeNI2Mj12Zk63AMC3vI=
github.com/0xProject/go-ws-transport v0.1.1-0.20200201000210-2db3396fec39/go.mod h1:9BHJz/4Q5A9ludYWKoGCFC5gUElzlHoKzu0yY9p/klM=
github.com/0xProject/go-ws-transport v0.1.1-0.20200530011125-b4ab00766967 h1:D7HZfoMYUXCYTVflLSqAXvCTotwR3cQn8s9peVA3/5M=
github.com/0xProject/go-ws-transport v0.1.1-0.20200530011125-b4ab00766967/go.mod h1:u/HmnXUDjrIk299j/U0prf1a/BOO8xky3ekSk9YkZdY=
github.com/0xProject/go-ws-transport v0.1.1-0.20200602173532-300f0ff55a11 h1:4FnZlElDsHYCEMeTEj2oS/tzzulsQU0ytrZiNpbE8SA=
github.com/0xProject/go-ws-transport v0.1.1-0.20200602173532-300f0ff55a11/go.mod h1:u/HmnXUDjrIk299j/U0prf1a/BOO8xky3ekSk9YkZdY=
github.com/0xProject/goleveldb v1.0.1-0.20191115232649-6a187a47701c h1:sMhvadadLwwpHsq4hDRAd+lcmQHJYpn44Oe9f7sFTmA=
github.com/0xProject/goleveldb v1.0.1-0.20191115232649-6a187a47701c/go.mod h1:vCim/erjgVmww+K+tF4+tf/zs63CPRiOtgdXqLgTM1Q=
github.com/0xProject/goleveldb v1.0.1-0.20200530004603-c3409ec0ad1a h1:slc00OPeLlw+7paAFj5pio5PrGatKRk3eLc2I5H8MN0=
github.com/0xProject/goleveldb v1.0.1-0.20200530004603-c3409ec0ad1a/go.mod h1:1Jo/RG6qMRJ3cgqzUqRWw592pkpuDJDKCIhMNXK5ar4=
github.com/0xProject/goleveldb v1.0.1-0.20200530004936-22bf95dd2954 h1:11Y2r6UKXZZSA7SAfd50pJ1wFRgOEjLlZTJ3orOCAoE=
github.com/0xProject/goleveldb v1.0.1-0.20200530004936-22bf95dd2954/go.mod h1:1Jo/RG6qMRJ3cgqzUqRWw592pkpuDJDKCIhMNXK5ar4=
github.com/0xProject/goleveldb v1.0.1-0.20200602173211-6ee893c9b83a h1:7V/u2CwtbkJCQ4ctMzIMtxF8I1W1obt+y9zxw71Chg4=
github.com/0xProject/goleveldb v1.0.1-0.20200602173211-6ee893c9b83a/go.mod h1:1Jo/RG6qMRJ3cgqzUqRWw592pkpuDJDKCIhMNXK5ar4=
github.com/0xProject/qunit v0.0.0-20190730000255-81c18fdf7752/go.mod h1:Onz5mS+Tpffz0tyRWdHDrqKcQ1ZFNeRhYHrNAkaMgeQ=
Expand Down Expand Up @@ -66,8 +39,6 @@ github.com/albrow/stringset v2.1.0+incompatible h1:P90SSV7fle22yLbhDSLRC8Jtec0tC
github.com/albrow/stringset v2.1.0+incompatible/go.mod h1:ltP0XRz96SPEM8ofD1BaE4IpTR2uCGSk6Z2VRfh1Llw=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/allegro/bigcache v0.0.0-20190618191010-69ea0af04088 h1:98xHUPwc06h3/UklWP/wZjARk6fxAFEGkEZ0E1UJReo=
github.com/allegro/bigcache v0.0.0-20190618191010-69ea0af04088/go.mod h1:qw9PmPMRP4u9TMCeXEA+M4m2lvVM+B/URHNUtxFcERc=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ=
Expand Down Expand Up @@ -109,7 +80,6 @@ github.com/chromedp/chromedp v0.4.0 h1:0AJC5ejETuh/6n7Tcsw4u4G0eKZkI9aVRwckWaImL
github.com/chromedp/chromedp v0.4.0/go.mod h1:DC3QUn4mJ24dwjcaGQLoZrhm4X/uPHZ6spDbS2uFhm4=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U=
github.com/coocood/freecache v1.1.0/go.mod h1:ePwxCDzOYvARfHdr1pByNct1at3CoKnsipOHwKlNbzI=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
Expand Down Expand Up @@ -151,8 +121,6 @@ github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlK
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gballet/go-libpcsclite v0.0.0-20190528105824-2fd9b619dd3c h1:gID5iWto0hEmbyMl+15Rkju0P+8uvF0jSn1cWdyv+5M=
github.com/gballet/go-libpcsclite v0.0.0-20190528105824-2fd9b619dd3c/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/gibson042/canonicaljson-go v1.0.3 h1:EAyF8L74AWabkyUmrvEFHEt/AGFQeD6RfwbAuf0j1bI=
Expand Down Expand Up @@ -457,10 +425,10 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/miekg/dns v1.1.12/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
Expand Down Expand Up @@ -530,8 +498,6 @@ github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXS
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0=
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
github.com/ocdogan/rbt v0.0.0-20160425054511-de6e2b48be33 h1:DQMe4Gmdz3tmthcNAbzAjW3Q7COoMi5Q2cJQnWsUkv8=
github.com/ocdogan/rbt v0.0.0-20160425054511-de6e2b48be33/go.mod h1:0uoVzTOFUpKmyAwRLuwFo79XnkqEuZzxnDqsCKlRT4I=
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88=
Expand All @@ -558,8 +524,6 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
Expand Down Expand Up @@ -606,12 +570,8 @@ github.com/src-d/envconfig v1.0.0/go.mod h1:Q9YQZ7BKITldTBnoxsE5gOeB5y66RyPXeue/
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
github.com/status-im/keycard-go v0.0.0-20190424133014-d95853db0f48 h1:ju5UTwk5Odtm4trrY+4Ca4RMj5OyXbmVeDAVad2T0Jw=
github.com/status-im/keycard-go v0.0.0-20190424133014-d95853db0f48/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
github.com/steakknife/bloomfilter v0.0.0-20180906043351-99ee86d9200f h1:T7YHzO3/eqD/kv5m9+TLM4XuEAkN7NPj5pnZHqaOo/Q=
github.com/steakknife/bloomfilter v0.0.0-20180906043351-99ee86d9200f/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw=
github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570 h1:gIlAHnH1vJb5vwEjIp5kBj/eu99p/bl0Ay2goiPe5xE=
github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw=
github.com/steakknife/hamming v0.0.0-20180906055317-003c143a81c2 h1:o6NMd68tuqfQ0ZFnz2d16xzFNLWxrCvqF40InOJJHSM=
github.com/steakknife/hamming v0.0.0-20180906055317-003c143a81c2/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU=
github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3 h1:njlZPzLwU639dk2kqnCPPv+wNjq7Xb6EfUxe/oX0/NM=
github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down Expand Up @@ -686,8 +646,6 @@ golang.org/x/net v0.0.0-20190227160552-c95aed5357e7/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 h1:Jcxah/M+oLZ/R4/z5RzfPzGbPXnVDPkEDtf2JnuxN+U=
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -754,8 +712,6 @@ gopkg.in/karlseguin/expect.v1 v1.0.1 h1:9u0iUltnhFbJTHaSIH0EP+cuTU5rafIgmcsEsg2J
gopkg.in/karlseguin/expect.v1 v1.0.1/go.mod h1:uB7QIJBcclvYbwlUDkSCsGjAOMis3fP280LyhuDEf2I=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20190709231704-1e4459ed25ff h1:uuol9OUzSvZntY1v963NAbVd7A+PHLMz1FlCe3Lorcs=
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20190709231704-1e4459ed25ff/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns=
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200316214253-d7b0ff38cac9 h1:ITeyKbRetrVzqR3U1eY+ywgp7IBspGd1U/bkwd1gWu4=
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200316214253-d7b0ff38cac9/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns=
gopkg.in/src-d/go-cli.v0 v0.0.0-20181105080154-d492247bbc0d/go.mod h1:z+K8VcOYVYcSwSjGebuDL6176A1XskgbtNl64NSg+n8=
Expand Down
23 changes: 14 additions & 9 deletions packages/browser/go/jsutil/jsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package jsutil

import (
"bytes"
"context"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -89,16 +88,22 @@ func AwaitPromise(promise js.Value) (result js.Value, err error) {
// InefficientlyConvertToJS converts the given Go value to a JS value by
// encoding to JSON and then decoding it. This function is not very efficient
// and its use should be phased out over time as much as possible.
func InefficientlyConvertToJS(value interface{}) (js.Value, error) {
var jsValue interface{}
buf := bytes.Buffer{}
if err := json.NewEncoder(&buf).Encode(value); err != nil {
return js.Undefined(), err
}
if err := json.NewDecoder(&buf).Decode(&jsValue); err != nil {
func InefficientlyConvertToJS(value interface{}) (result js.Value, err error) {
defer func() {
if e := recover(); e != nil {
switch e := e.(type) {
case error:
err = e
default:
err = fmt.Errorf("unexpected error: (%T) %s", e, e)
}
}
}()
jsonBytes, err := json.Marshal(value)
if err != nil {
return js.Undefined(), err
}
return js.ValueOf(jsValue), nil
return js.Global().Get("JSON").Call("parse", string(jsonBytes)), nil
}

// InefficientlyConvertFromJS converts the given JS value to a Go value and sets
Expand Down
108 changes: 108 additions & 0 deletions packages/browser/go/jsutil/jsutil_bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// +build js,wasm

package jsutil

import (
"fmt"
"math/cmplx"
"math/rand"
"testing"
"time"

"github.com/pborman/uuid"
)

type testValue struct {
Uint uint `json:"uint"`
Uint8 uint8 `json:"uint8"`
Uint16 uint16 `json:"uint16"`
Uint32 uint32 `json:"uint32"`
Uint64 uint64 `json:"uint64"`
Int int `json:"int"`
Int8 int8 `json:"int8"`
Int16 int16 `json:"int16"`
Int32 int32 `json:"int32"`
Int64 int64 `json:"int64"`
Float32 float32 `json:"float32"`
Float64 float64 `json:"float64"`
Byte byte `json:"byte"`
Rune rune `json:"rune"`
String string `json:"string"`
Bool bool `json:"bool"`
Time time.Time `json:"time"`
}

func newTestValue() *testValue {
return &testValue{
Uint: uint(randomInt()),
Uint8: uint8(randomInt()),
Uint16: uint16(randomInt()),
Uint32: uint32(randomInt()),
Uint64: uint64(randomInt()),
Int: randomInt(),
Int8: int8(randomInt()),
Int16: int16(randomInt()),
Int32: int32(randomInt()),
Int64: int64(randomInt()),
Float32: float32(randomInt()),
Float64: float64(randomInt()),
Byte: []byte(randomString())[0],
Rune: []rune(randomString())[0],
String: randomString(),
Bool: randomBool(),
Time: time.Now(),
}
}

func BenchmarkInefficientlyConvertToJS(b *testing.B) {
counts := []int{
1,
10,
100,
1000,
}
for _, count := range counts {
name := fmt.Sprintf("BenchmarkInefficientlyConvertToJS_%d", count)
b.Run(name, runBenchmarkInefficientlyConvertToJS(count))
}
}

func runBenchmarkInefficientlyConvertToJS(count int) func(*testing.B) {
return func(b *testing.B) {
values := []*testValue{}
for i := 0; i < count; i++ {
values = append(values, newTestValue())
}
b.ResetTimer()

for i := 0; i < b.N; i++ {
_, _ = InefficientlyConvertToJS(values)
}
}
}

// randomInt returns a pseudo-random int between the minimum and maximum
// possible values.
func randomInt() int {
return rand.Int()
}

// randomString returns a random string of length 16
func randomString() string {
return uuid.New()
}

// randomBool returns a random bool
func randomBool() bool {
return rand.Int()%2 == 0
}

// randomFloat returns a random float64
func randomFloat() float64 {
return rand.Float64()
}

// randomComplex returns a random complex128
func randomComplex() complex128 {
return cmplx.Rect(randomFloat(), randomFloat())
}

0 comments on commit c593d51

Please sign in to comment.