closure-compiler
closure-compiler copied to clipboard
Keep long bigint literals in hexadecimal format
Long bigint literals written in hexadecimal format (such as 0x123456789ABDEFn
) should be kept as is. Currently GCC expands them to decimal bigint literals, which increases the compiled size significantly (up to ~20%).
Example:
const P = 0x2fadbe2852044d028597455bc2abbd1bc873af205dfabb8a304600f3e09eeba8n;
console.log(P);
is transformed to
console.log(21565680844461314807147611702860246336805372493508489110556896454939225549736n)
Many crypto libraries (hashing, verifiable computation, etc) include long list of large constants. Keeping such constants in hexadecimal form makes a big difference.
Writing the literals as BigInt("0xabc")
is a workaround but is not ideal due to increased compiled size and runtime cost.
This incurs up to 20% blow up in compiled code size.