mirror of https://github.com/golang/go.git
improve memory efficiency of OID String() method
This commit is contained in:
parent
0aa14fca8c
commit
ff350b7e71
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue