From 939f3eee97f6f928b756f53c0f88456a61ef2206 Mon Sep 17 00:00:00 2001 From: Deluan Date: Wed, 5 Jun 2024 23:00:36 -0400 Subject: [PATCH] Initialize Index Groups regex just once --- utils/index_group_parser.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/index_group_parser.go b/utils/index_group_parser.go index 76a40764..71406233 100644 --- a/utils/index_group_parser.go +++ b/utils/index_group_parser.go @@ -18,12 +18,14 @@ type IndexGroups map[string]string // for grouping accented characters (such as A, \u00C0 and \u00C1) // // Files and folders that are not covered by an index entry will be placed under the index entry "#". + +var indexGroupsRx = regexp.MustCompile(`(.+)\((.+)\)`) + func ParseIndexGroups(spec string) IndexGroups { parsed := make(IndexGroups) split := strings.Split(spec, " ") - re := regexp.MustCompile(`(.+)\((.+)\)`) for _, g := range split { - sub := re.FindStringSubmatch(g) + sub := indexGroupsRx.FindStringSubmatch(g) if len(sub) > 0 { i := 0 chars := strings.Split(sub[2], "")