File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
10
10
"bytes"
11
11
"path/filepath"
12
12
"strings"
13
+ "sync"
13
14
14
15
"code.gitea.io/gitea/modules/log"
15
16
"code.gitea.io/gitea/modules/setting"
@@ -21,14 +22,18 @@ import (
21
22
var (
22
23
// For custom user mapping
23
24
highlightMapping = map [string ]string {}
25
+
26
+ once sync.Once
24
27
)
25
28
26
29
// NewContext loads highlight map
27
30
func NewContext () {
28
- keys := setting .Cfg .Section ("highlight.mapping" ).Keys ()
29
- for i := range keys {
30
- highlightMapping [keys [i ].Name ()] = keys [i ].Value ()
31
- }
31
+ once .Do (func () {
32
+ keys := setting .Cfg .Section ("highlight.mapping" ).Keys ()
33
+ for i := range keys {
34
+ highlightMapping [keys [i ].Name ()] = keys [i ].Value ()
35
+ }
36
+ })
32
37
}
33
38
34
39
// Code returns a HTML version of code string with chroma syntax highlighting classes
You can’t perform that action at this time.
0 commit comments