google / closure-compiler

A JavaScript checker and optimizer.
https://developers.google.com/closure/compiler/
Apache License 2.0
7.41k stars 1.15k forks source link

Emit BigInt literals in hexadecimal if shorter (#4165) #4166

Closed KimlikDAO-bot closed 5 months ago

KimlikDAO-bot commented 6 months ago

Emit BigInt literals in hexadecimal format if it leads to shorter code size. This is important for cryptographic libraries, especially in verifiable computation, which have long list of large constants.

The exact threshold after which hexadecimal is shorter is 10^17, however to keep the code simple and extensible, we calculate both the decimal and hexadecimal encodings and compare their sizes.

While both f = (x) => x.toString(16).length + 2 and g = (x) => x.toString().length are monotone, the difference of two monotone functions is not generally monotone. The above comment is incorrect, though the code is correct as is.

google-cla[bot] commented 6 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

blickly commented 5 months ago

Thanks for the contribution!