aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/math/big/nat.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/math/big/nat.go b/src/math/big/nat.go
index 5f5cf5c3e4..1e4a3b09cf 100644
--- a/src/math/big/nat.go
+++ b/src/math/big/nat.go
@@ -58,6 +58,10 @@ func (z nat) make(n int) nat {
if n <= cap(z) {
return z[:n] // reuse z
}
+ if n == 1 {
+ // Most nats start small and stay that way; don't over-allocate.
+ return make(nat, 1)
+ }
// Choosing a good value for e has significant performance impact
// because it increases the chance that a value can be reused.
const e = 4 // extra capacity