diff options
author | Filip Navara <filip.navara@gmail.com> | 2019-04-30 15:27:41 +0200 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-04-30 16:27:41 +0300 |
commit | 55daee8d22c964f2f7b362d0f5e6a7031bbd535d (patch) | |
tree | cc74544f8000f8de56aa607cf544d3a6977583d5 /modules/git | |
parent | 9b9ec7847cd9e85f21fc10cd881e39d1fef66961 (diff) | |
download | gitea-55daee8d22c964f2f7b362d0f5e6a7031bbd535d.tar.gz gitea-55daee8d22c964f2f7b362d0f5e6a7031bbd535d.zip |
Remove `seen` map from `getLastCommitForPaths` (#6807)
Ensures correctly traversing the commit graph for all path and avoids
erroneously skipping some. Also preallocate some arrays to correct size
to prevent unnecessary reallocations.
Fixes #6708.
Signed-off-by: Filip Navara <filip.navara@gmail.com>
Diffstat (limited to 'modules/git')
-rw-r--r-- | modules/git/commit_info.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/modules/git/commit_info.go b/modules/git/commit_info.go index 21ecd57ac2..da430a21cd 100644 --- a/modules/git/commit_info.go +++ b/modules/git/commit_info.go @@ -124,7 +124,6 @@ func getFileHashes(c *object.Commit, treePath string, paths []string) (map[strin func getLastCommitForPaths(c *object.Commit, treePath string, paths []string) (map[string]*object.Commit, error) { // We do a tree traversal with nodes sorted by commit time - seen := make(map[plumbing.Hash]bool) heap := binaryheap.NewWith(func(a, b interface{}) int { if a.(*commitAndPaths).commit.Committer.When.Before(b.(*commitAndPaths).commit.Committer.When) { return 1 @@ -202,15 +201,10 @@ func getLastCommitForPaths(c *object.Commit, treePath string, paths []string) (m // Add the parent nodes along with remaining paths to the heap for further // processing. for j, parent := range parents { - if seen[parent.ID()] { - continue - } - seen[parent.ID()] = true - // Combine remainingPath with paths available on the parent branch // and make union of them - var remainingPathsForParent []string - var newRemainingPaths []string + remainingPathsForParent := make([]string, 0, len(remainingPaths)) + newRemainingPaths := make([]string, 0, len(remainingPaths)) for _, path := range remainingPaths { if parentHashes[j][path] == current.hashes[path] { remainingPathsForParent = append(remainingPathsForParent, path) |