From 113843a69ced8d15be7126bf6bcf2d36544cecfc Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Wed, 24 May 2023 16:15:34 +0200 Subject: [PATCH] Preallocate for common case in base58 decode, expose preallocated case --- base58.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/base58.go b/base58.go index 4e954db..9ecdaac 100644 --- a/base58.go +++ b/base58.go @@ -91,6 +91,12 @@ func EncodeMoneroBase58(data ...[]byte) string { } func DecodeMoneroBase58(data string) (result []byte) { + //common case + return DecodeMoneroBase58PreAllocated(make([]byte, 0, 69), data) +} + +func DecodeMoneroBase58PreAllocated(buf []byte, data string) (result []byte) { + result = buf length := len(data) rounds := length / 11 for i := 0; i < rounds; i++ {