Preallocate space for the answer in Base58Encode.
Benchmarks show this makes Base58Encode twice as fast.
This commit is contained in:
parent
e622fde7e7
commit
190c86b2bf
1 changed files with 1 additions and 1 deletions
|
@ -53,7 +53,7 @@ func Base58Encode(b []byte) string {
|
|||
x := new(big.Int)
|
||||
x.SetBytes(b)
|
||||
|
||||
answer := make([]byte, 0)
|
||||
answer := make([]byte, 0, len(b)*136/100)
|
||||
for x.Cmp(bigZero) > 0 {
|
||||
mod := new(big.Int)
|
||||
x.DivMod(x, bigRadix, mod)
|
||||
|
|
Loading…
Reference in a new issue