improve memory efficiency of OID String() method

This commit is contained in:
Mateusz Poliwczak 2023-03-23 11:19:29 +01:00
parent 0aa14fca8c
commit ff350b7e71
1 changed files with 6 additions and 4 deletions

View File

@ -26,6 +26,7 @@ import (
"math/big"
"reflect"
"strconv"
"strings"
"time"
"unicode/utf16"
"unicode/utf8"
@ -236,16 +237,17 @@ func (oi ObjectIdentifier) Equal(other ObjectIdentifier) bool {
}
func (oi ObjectIdentifier) String() string {
var s string
var s strings.Builder
s.Grow(32)
for i, v := range oi {
if i > 0 {
s += "."
s.WriteByte('.')
}
s += strconv.Itoa(v)
s.Write(strconv.AppendInt(make([]byte, 0, 16), int64(v), 10))
}
return s
return s.String()
}
// parseObjectIdentifier parses an OBJECT IDENTIFIER from the given bytes and