Skip to content

🎧 Your Personal Streaming Service

Initialize Index Groups regex just once

Deluan939f3eee97f6
diff --git a/utils/index_group_parser.go b/utils/index_group_parser.go
index 76a407646..714062334 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], "")