Preallocate for common case in base58 decode, expose preallocated case
This commit is contained in:
parent
a566889a4d
commit
113843a69c
|
@ -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++ {
|
||||
|
|
Reference in a new issue