aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/klauspost/compress/zstd/enc_better.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-04-29 05:56:13 -0400
committerGitHub <noreply@github.com>2021-04-29 05:56:13 -0400
commit386b7f94f30ebb67e0073e0d31a9f203f0ac6db7 (patch)
treef7e75f22fb25c5a790485ddedff5e75aaa783760 /vendor/github.com/klauspost/compress/zstd/enc_better.go
parentdb67fedcbd1fcaf06d0d6655face5182ccd0cc87 (diff)
parent3645db969891230db126ca8f35ccad3cd40af8f0 (diff)
downloadpodman-386b7f94f30ebb67e0073e0d31a9f203f0ac6db7.tar.gz
podman-386b7f94f30ebb67e0073e0d31a9f203f0ac6db7.tar.bz2
podman-386b7f94f30ebb67e0073e0d31a9f203f0ac6db7.zip
Merge pull request #10172 from containers/dependabot/go_modules/github.com/containers/storage-1.30.1
Bump github.com/containers/storage from 1.30.0 to 1.30.1
Diffstat (limited to 'vendor/github.com/klauspost/compress/zstd/enc_better.go')
-rw-r--r--vendor/github.com/klauspost/compress/zstd/enc_better.go73
1 files changed, 69 insertions, 4 deletions
diff --git a/vendor/github.com/klauspost/compress/zstd/enc_better.go b/vendor/github.com/klauspost/compress/zstd/enc_better.go
index c2ce4a2ba..604954290 100644
--- a/vendor/github.com/klauspost/compress/zstd/enc_better.go
+++ b/vendor/github.com/klauspost/compress/zstd/enc_better.go
@@ -412,8 +412,41 @@ encodeLoop:
cv = load6432(src, s)
}
- // A 4-byte match has been found. Update recent offsets.
- // We'll later see if more than 4 bytes.
+ // Try to find a better match by searching for a long match at the end of the current best match
+ if true && s+matched < sLimit {
+ nextHashL := hash8(load6432(src, s+matched), betterLongTableBits)
+ cv := load3232(src, s)
+ candidateL := e.longTable[nextHashL]
+ coffsetL := candidateL.offset - e.cur - matched
+ if coffsetL >= 0 && coffsetL < s && s-coffsetL < e.maxMatchOff && cv == load3232(src, coffsetL) {
+ // Found a long match, at least 4 bytes.
+ matchedNext := e.matchlen(s+4, coffsetL+4, src) + 4
+ if matchedNext > matched {
+ t = coffsetL
+ matched = matchedNext
+ if debugMatches {
+ println("long match at end-of-match")
+ }
+ }
+ }
+
+ // Check prev long...
+ if true {
+ coffsetL = candidateL.prev - e.cur - matched
+ if coffsetL >= 0 && coffsetL < s && s-coffsetL < e.maxMatchOff && cv == load3232(src, coffsetL) {
+ // Found a long match, at least 4 bytes.
+ matchedNext := e.matchlen(s+4, coffsetL+4, src) + 4
+ if matchedNext > matched {
+ t = coffsetL
+ matched = matchedNext
+ if debugMatches {
+ println("prev long match at end-of-match")
+ }
+ }
+ }
+ }
+ }
+ // A match has been found. Update recent offsets.
offset2 = offset1
offset1 = s - t
@@ -905,9 +938,41 @@ encodeLoop:
}
cv = load6432(src, s)
}
+ // Try to find a better match by searching for a long match at the end of the current best match
+ if s+matched < sLimit {
+ nextHashL := hash8(load6432(src, s+matched), betterLongTableBits)
+ cv := load3232(src, s)
+ candidateL := e.longTable[nextHashL]
+ coffsetL := candidateL.offset - e.cur - matched
+ if coffsetL >= 0 && coffsetL < s && s-coffsetL < e.maxMatchOff && cv == load3232(src, coffsetL) {
+ // Found a long match, at least 4 bytes.
+ matchedNext := e.matchlen(s+4, coffsetL+4, src) + 4
+ if matchedNext > matched {
+ t = coffsetL
+ matched = matchedNext
+ if debugMatches {
+ println("long match at end-of-match")
+ }
+ }
+ }
- // A 4-byte match has been found. Update recent offsets.
- // We'll later see if more than 4 bytes.
+ // Check prev long...
+ if true {
+ coffsetL = candidateL.prev - e.cur - matched
+ if coffsetL >= 0 && coffsetL < s && s-coffsetL < e.maxMatchOff && cv == load3232(src, coffsetL) {
+ // Found a long match, at least 4 bytes.
+ matchedNext := e.matchlen(s+4, coffsetL+4, src) + 4
+ if matchedNext > matched {
+ t = coffsetL
+ matched = matchedNext
+ if debugMatches {
+ println("prev long match at end-of-match")
+ }
+ }
+ }
+ }
+ }
+ // A match has been found. Update recent offsets.
offset2 = offset1
offset1 = s - t