internal/core/convert: avoid an allocation for "small" big.Int values
If we can represent the integer as an int64,
the conversion from math/big.Int to apd.Decimal does not need to go
through an extra apd.BigInt step, which also allocates.
│ old │ new │
│ B/op │ B/op vs base │
VetInventory 4.627Gi ± ∞ ¹ 4.618Gi ± ∞ ¹ -0.20% (p=1.000 n=1)
│ old │ new │
│ allocs/op │ allocs/op vs base │
VetInventory 49.61M ± ∞ ¹ 49.29M ± ∞ ¹ -0.64% (p=1.000 n=1)
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I08fcf54ef76ff4d16b531b278cfce79a1ef368ec
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1229430
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Matthew Sackman <matthew@cue.works>