diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-10-04 13:26:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-04 13:26:38 -0700 |
commit | 2c2782a2179aee6c76d90e864708e2e5ceb09349 (patch) | |
tree | c61aa40e008b7fcb371d899880a4afd1714f50af /vendor/github.com/klauspost/compress/zstd/enc_dfast.go | |
parent | bd08fc0e9b3a9943008585879877b68789e38c31 (diff) | |
parent | d3f59bedb393521986e645bc48c47938f321b643 (diff) | |
download | podman-2c2782a2179aee6c76d90e864708e2e5ceb09349.tar.gz podman-2c2782a2179aee6c76d90e864708e2e5ceb09349.tar.bz2 podman-2c2782a2179aee6c76d90e864708e2e5ceb09349.zip |
Merge pull request #4165 from mtrmac/c-image-4
Update c/image to v4.0.0 + Buildah to 1.11.3
Diffstat (limited to 'vendor/github.com/klauspost/compress/zstd/enc_dfast.go')
-rw-r--r-- | vendor/github.com/klauspost/compress/zstd/enc_dfast.go | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/vendor/github.com/klauspost/compress/zstd/enc_dfast.go b/vendor/github.com/klauspost/compress/zstd/enc_dfast.go index 02c79814f..e120625d8 100644 --- a/vendor/github.com/klauspost/compress/zstd/enc_dfast.go +++ b/vendor/github.com/klauspost/compress/zstd/enc_dfast.go @@ -82,16 +82,11 @@ func (e *doubleFastEncoder) Encode(blk *blockEnc, src []byte) { stepSize++ } - // TEMPLATE - const kSearchStrength = 8 // nextEmit is where in src the next emitLiteral should start from. nextEmit := s cv := load6432(src, s) - // nextHash is the hash at s - nextHashS := hash5(cv, dFastShortTableBits) - nextHashL := hash8(cv, dFastLongTableBits) // Relative offsets offset1 := int32(blk.recentOffsets[0]) @@ -119,8 +114,8 @@ encodeLoop: panic("offset0 was 0") } - nextHashS = nextHashS & dFastShortTableMask - nextHashL = nextHashL & dFastLongTableMask + nextHashS := hash5(cv, dFastShortTableBits) + nextHashL := hash8(cv, dFastLongTableBits) candidateL := e.longTable[nextHashL] candidateS := e.table[nextHashS] @@ -172,8 +167,6 @@ encodeLoop: break encodeLoop } cv = load6432(src, s) - nextHashS = hash5(cv, dFastShortTableBits) - nextHashL = hash8(cv, dFastLongTableBits) continue } const repOff2 = 1 @@ -221,8 +214,6 @@ encodeLoop: break encodeLoop } cv = load6432(src, s) - nextHashS = hash5(cv, dFastShortTableBits) - nextHashL = hash8(cv, dFastLongTableBits) // Swap offsets offset1, offset2 = offset2, offset1 continue @@ -296,8 +287,6 @@ encodeLoop: break encodeLoop } cv = load6432(src, s) - nextHashS = hash5(cv, dFastShortTableBits) - nextHashL = hash8(cv, dFastLongTableBits) } // A 4-byte match has been found. Update recent offsets. @@ -345,38 +334,54 @@ encodeLoop: break encodeLoop } - // Index match start + 2 and end - 2 - index0 := s - l + 2 + // Index match start+1 (long) and start+2 (short) + index0 := s - l + 1 + // Index match end-2 (long) and end-1 (short) index1 := s - 2 - if l == 4 { - // if l is 4, we would check the same place twice, so index s-1 instead. - index1++ - } cv0 := load6432(src, index0) cv1 := load6432(src, index1) - entry0 := tableEntry{offset: index0 + e.cur, val: uint32(cv0)} - entry1 := tableEntry{offset: index1 + e.cur, val: uint32(cv1)} - e.table[hash5(cv0, dFastShortTableBits)&dFastShortTableMask] = entry0 - e.longTable[hash8(cv0, dFastLongTableBits)&dFastLongTableMask] = entry0 - e.table[hash5(cv1, dFastShortTableBits)&dFastShortTableMask] = entry1 - e.longTable[hash8(cv1, dFastLongTableBits)&dFastLongTableMask] = entry1 + te0 := tableEntry{offset: index0 + e.cur, val: uint32(cv0)} + te1 := tableEntry{offset: index1 + e.cur, val: uint32(cv1)} + e.longTable[hash8(cv0, dFastLongTableBits)] = te0 + e.longTable[hash8(cv1, dFastLongTableBits)] = te1 + cv0 >>= 8 + cv1 >>= 8 + te0.offset++ + te1.offset++ + te0.val = uint32(cv0) + te1.val = uint32(cv1) + e.table[hash5(cv0, dFastShortTableBits)] = te0 + e.table[hash5(cv1, dFastShortTableBits)] = te1 cv = load6432(src, s) - nextHashS = hash5(cv, dFastShortTableBits) - nextHashL = hash8(cv, dFastLongTableBits) + + if !canRepeat { + continue + } // Check offset 2 - if o2 := s - offset2; canRepeat && o2 > 0 && load3232(src, o2) == uint32(cv) { + for { + o2 := s - offset2 + if load3232(src, o2) != uint32(cv) { + // Do regular search + break + } + + // Store this, since we have it. + nextHashS := hash5(cv1>>8, dFastShortTableBits) + nextHashL := hash8(cv, dFastLongTableBits) + // We have at least 4 byte match. // No need to check backwards. We come straight from a match l := 4 + e.matchlen(s+4, o2+4, src) - // Store this, since we have it. + entry := tableEntry{offset: s + e.cur, val: uint32(cv)} - e.longTable[nextHashL&dFastLongTableMask] = entry - e.table[nextHashS&dFastShortTableMask] = entry + e.longTable[nextHashL] = entry + e.table[nextHashS] = entry seq.matchLen = uint32(l) - zstdMinMatch seq.litLen = 0 + // Since litlen is always 0, this is offset 1. seq.offset = 1 s += l @@ -389,12 +394,10 @@ encodeLoop: // Swap offset 1 and 2. offset1, offset2 = offset2, offset1 if s >= sLimit { + // Finished break encodeLoop } - // Prepare next loop. cv = load6432(src, s) - nextHashS = hash5(cv, dFastShortTableBits) - nextHashL = hash8(cv, dFastLongTableBits) } } |