diff options
Diffstat (limited to 'libgo/go/encoding/asn1/common.go')
-rw-r--r-- | libgo/go/encoding/asn1/common.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libgo/go/encoding/asn1/common.go b/libgo/go/encoding/asn1/common.go index e2aa8bd..1c712e1 100644 --- a/libgo/go/encoding/asn1/common.go +++ b/libgo/go/encoding/asn1/common.go @@ -92,7 +92,16 @@ type fieldParameters struct { // parseFieldParameters will parse it into a fieldParameters structure, // ignoring unknown parts of the string. func parseFieldParameters(str string) (ret fieldParameters) { - for _, part := range strings.Split(str, ",") { + var part string + for len(str) > 0 { + // This loop uses IndexByte and explicit slicing + // instead of strings.Split(str, ",") to reduce allocations. + i := strings.IndexByte(str, ',') + if i < 0 { + part, str = str, "" + } else { + part, str = str[:i], str[i+1:] + } switch { case part == "optional": ret.optional = true |