diff --git a/.changelog/0e1f4e3313a449c8b2230d6cc756ef18.json b/.changelog/0e1f4e3313a449c8b2230d6cc756ef18.json new file mode 100644 index 00000000000..aaa553a117e --- /dev/null +++ b/.changelog/0e1f4e3313a449c8b2230d6cc756ef18.json @@ -0,0 +1,8 @@ +{ + "id": "0e1f4e33-13a4-49c8-b223-0d6cc756ef18", + "type": "bugfix", + "description": "Fix subproperty performance regression", + "modules": [ + "internal/ini" + ] +} \ No newline at end of file diff --git a/internal/ini/literal_tokens.go b/internal/ini/literal_tokens.go index a24903202ac..f0372a68ef0 100644 --- a/internal/ini/literal_tokens.go +++ b/internal/ini/literal_tokens.go @@ -133,6 +133,17 @@ func newLitToken(b []rune) (Token, int, error) { return token, n, err } +// replace with slices.Contains when Go 1.21 +// is min supported Go version in the SDK +func containsRune(runes []rune, val rune) bool { + for i := range runes { + if val == runes[i] { + return true + } + } + return false +} + func isSubProperty(runes []rune) bool { // needs at least // (1) newline (2) whitespace (3) literal @@ -141,10 +152,7 @@ func isSubProperty(runes []rune) bool { } // must have an equal expression - split := strings.FieldsFunc(string(runes), func(r rune) bool { - return isOp([]rune{r}) - }) - if len(split) < 2 { + if !containsRune(runes, '=') && !containsRune(runes, ':') { return false } @@ -156,7 +164,6 @@ func isSubProperty(runes []rune) bool { if err != nil { return false } - // whitespace must follow newline return isWhitespace(runes[n]) }