in cvefeed/nvd/smartvercmp.go [63:87]
func parseVerParts(v string) (int, int, int) {
var num int
for num = 0; num < len(v); num++ {
if v[num] < '0' || v[num] > '9' {
break
}
}
if num == len(v) {
return num, num, num
}
// Any punctuation separates the parts.
skip := strings.IndexFunc(v, func(b rune) bool {
// !"#$%&'()*+,-./ are dec 33 to 47, :;<=>?@ are dec 58 to 64, [\]^_` are dec 91 to 96 and {|}~ are dec 123 to 126.
// So, punctuation is in dec 33-126 range except 48-57, 65-90 and 97-122 gaps.
// This inverse logic allows for early short-circuting for most of the chars and shaves ~20ns in benchmarks.
return b >= '!' && b <= '~' &&
!(b > '/' && b < ':' ||
b > '@' && b < '[' ||
b > '`' && b < '{')
})
if skip == -1 {
return num, len(v), len(v)
}
return num, skip, skip + 1
}