aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2024-07-31 17:38:26 +0100
committerGitHub <noreply@github.com>2024-07-31 17:38:26 +0100
commit61f8d68aae95647f21a7d0983a428363acac8782 (patch)
treec0b224f476ec1e461f4915d8b1fea9c8f3e0f5f7
parent9debed20a8955b622cea335ddc1144dd452f417b (diff)
parent3a3f96c372b0f9a93ea27928baa4516e95a79bde (diff)
downloadgo-git-61f8d68aae95647f21a7d0983a428363acac8782.tar.gz
Merge pull request #1152 from edigaryev/remove-duplicate-checks
plumbing: format/packfile, remove duplicate checks in findMatch()
-rw-r--r--plumbing/format/packfile/delta_index.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/plumbing/format/packfile/delta_index.go b/plumbing/format/packfile/delta_index.go
index 07a6112..a60ec0b 100644
--- a/plumbing/format/packfile/delta_index.go
+++ b/plumbing/format/packfile/delta_index.go
@@ -32,19 +32,17 @@ func (idx *deltaIndex) findMatch(src, tgt []byte, tgtOffset int) (srcOffset, l i
return 0, -1
}
- if len(tgt) >= tgtOffset+s && len(src) >= blksz {
- h := hashBlock(tgt, tgtOffset)
- tIdx := h & idx.mask
- eIdx := idx.table[tIdx]
- if eIdx != 0 {
- srcOffset = idx.entries[eIdx]
- } else {
- return
- }
-
- l = matchLength(src, tgt, tgtOffset, srcOffset)
+ h := hashBlock(tgt, tgtOffset)
+ tIdx := h & idx.mask
+ eIdx := idx.table[tIdx]
+ if eIdx == 0 {
+ return
}
+ srcOffset = idx.entries[eIdx]
+
+ l = matchLength(src, tgt, tgtOffset, srcOffset)
+
return
}