@@ -6,19 +6,12 @@ package git
66import (
77 "crypto/sha256"
88 "fmt"
9- "sync"
109
1110 "code.gitea.io/gitea/modules/cache"
1211 "code.gitea.io/gitea/modules/log"
1312 "code.gitea.io/gitea/modules/setting"
1413)
1514
16- var lastCommitPool = sync.Pool {
17- New : func () any {
18- return & Commit {}
19- },
20- }
21-
2215func getCacheKey (repoPath , commitID , entryPath string ) string {
2316 hashBytes := sha256 .Sum256 ([]byte (fmt .Sprintf ("%s:%s:%s" , repoPath , commitID , entryPath )))
2417 return fmt .Sprintf ("last_commit:%x" , hashBytes )
@@ -65,25 +58,20 @@ func (c *LastCommitCache) Get(ref, entryPath string) (*Commit, error) {
6558 return nil , nil
6659 }
6760
68- commit := lastCommitPool .Get ().(* Commit )
69- defer lastCommitPool .Put (commit )
70- var err error
71- var ok bool
72-
7361 commitID , ok := c .cache .Get (getCacheKey (c .repoPath , ref , entryPath ))
7462 if ! ok || commitID == "" {
7563 return nil , nil
7664 }
7765
7866 log .Debug ("LastCommitCache hit level 1: [%s:%s:%s]" , ref , entryPath , commitID )
7967 if c .commitCache != nil {
80- if commit , ok = c .commitCache [commitID ]; ok {
68+ if commit , ok : = c .commitCache [commitID ]; ok {
8169 log .Debug ("LastCommitCache hit level 2: [%s:%s:%s]" , ref , entryPath , commitID )
8270 return commit , nil
8371 }
8472 }
8573
86- commit , err = c .repo .GetCommit (commitID )
74+ commit , err : = c .repo .GetCommit (commitID )
8775 if err != nil {
8876 return nil , err
8977 }
0 commit comments