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

Optimize InefficientlyConvertToJS #820

Merged
merged 3 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
jalextowle marked this conversation as resolved.
Show resolved Hide resolved
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hypothetically, these test values could skew the benchmark if the savings are considerably different for small number types compared to things like large strings. I think that it would be good to benchmark against arrays of asset data, big ints, or a mix of types that better describe our use case (like zeroex.SignedOrder).

This is not to say that this benchmark is not useful. I just think that it would be good to have one more that is more tailored to our use-case.

Copy link
Contributor Author

@albrow albrow Jun 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no single type that we could use here that would cover all the places we use InefficientlyConvertToJS throughout the codebase. The idea here is just to give us a decent idea of how InefficientlyConvertToJS performs generally. Based on what I have seen so far, I think it is extremely unlikely that this change will make InefficientlyConvertToJS slower, no mater what type we are converting.

If we have a need to optimize the encoding/conversion of a specific type (e.g. in the db package), we should just use a separate benchmark that looks at that type specifically.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think that’s unlikely. I think the real point is that we should have some benchmarks on more realistic benchmarks to see how much of a performance boost we get for Mesh specific use cases.

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())
}