Initialize Index Groups regex just once

This commit is contained in:
Deluan 2024-06-05 23:00:36 -04:00
parent b4ef1b1e38
commit 939f3eee97
1 changed files with 4 additions and 2 deletions

View File

@ -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], "")