File tree Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -997,7 +997,9 @@ func sha1CurrentPatternProcessor(ctx *RenderContext, node *html.Node) {
997
997
998
998
start := 0
999
999
next := node .NextSibling
1000
- cache := make (map [string ]bool )
1000
+ if ctx .ShaExistCache == nil {
1001
+ ctx .ShaExistCache = make (map [string ]bool )
1002
+ }
1001
1003
for node != nil && node != next && start < len (node .Data ) {
1002
1004
m := sha1CurrentPattern .FindStringSubmatchIndex (node .Data [start :])
1003
1005
if m == nil {
@@ -1017,7 +1019,7 @@ func sha1CurrentPatternProcessor(ctx *RenderContext, node *html.Node) {
1017
1019
// a commit in the repository before making it a link.
1018
1020
1019
1021
// check cache first
1020
- exist , inCache := cache [hash ]
1022
+ exist , inCache := ctx . ShaExistCache [hash ]
1021
1023
if ! inCache {
1022
1024
if ctx .GitRepo == nil {
1023
1025
var err error
@@ -1033,7 +1035,7 @@ func sha1CurrentPatternProcessor(ctx *RenderContext, node *html.Node) {
1033
1035
}
1034
1036
1035
1037
exist = ctx .GitRepo .IsObjectExist (hash )
1036
- cache [hash ] = exist
1038
+ ctx . ShaExistCache [hash ] = exist
1037
1039
}
1038
1040
1039
1041
if ! exist {
Original file line number Diff line number Diff line change @@ -36,20 +36,25 @@ func Init() {
36
36
37
37
// RenderContext represents a render context
38
38
type RenderContext struct {
39
- Ctx context.Context
40
- Filename string
41
- Type string
42
- IsWiki bool
43
- URLPrefix string
44
- Metas map [string ]string
45
- DefaultLink string
46
- GitRepo * git.Repository
47
- cancelFn func ()
39
+ Ctx context.Context
40
+ Filename string
41
+ Type string
42
+ IsWiki bool
43
+ URLPrefix string
44
+ Metas map [string ]string
45
+ DefaultLink string
46
+ GitRepo * git.Repository
47
+ ShaExistCache map [string ]bool
48
+ cancelFn func ()
48
49
}
49
50
50
51
// Cancel runs any cleanup functions that have been registered for this Ctx
51
52
func (ctx * RenderContext ) Cancel () {
52
- if ctx == nil || ctx .cancelFn == nil {
53
+ if ctx == nil {
54
+ return
55
+ }
56
+ ctx .ShaExistCache = map [string ]bool {}
57
+ if ctx .cancelFn == nil {
53
58
return
54
59
}
55
60
ctx .cancelFn ()
You can’t perform that action at this time.
0 commit comments