1
1
mirror of https://github.com/walles/moar.git synced 2024-09-11 12:15:43 +03:00

30% faster search performance

This commit is contained in:
Johan Walles 2022-10-29 16:50:42 +02:00
parent b7ad10fda6
commit 0260da08a5

View File

@ -126,7 +126,12 @@ func withoutFormatting(s string) string {
stripped := strings.Builder{}
runeCount := 0
stripped.Grow(len(s))
// " * 2" here makes BenchmarkPlainTextSearch() perform 30% faster. Probably
// due to avoiding a number of additional implicit Grow() calls when adding
// runes.
stripped.Grow(len(s) * 2)
for _, styledString := range styledStringsFromString(s).styledStrings {
for _, runeValue := range runesFromStyledString(styledString) {
switch runeValue {