summaryrefslogtreecommitdiff
path: root/vendor/github.com/klauspost/compress/s2/encode_better.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/klauspost/compress/s2/encode_better.go')
-rw-r--r--vendor/github.com/klauspost/compress/s2/encode_better.go44
1 files changed, 25 insertions, 19 deletions
diff --git a/vendor/github.com/klauspost/compress/s2/encode_better.go b/vendor/github.com/klauspost/compress/s2/encode_better.go
index f46adb411..544cb1e17 100644
--- a/vendor/github.com/klauspost/compress/s2/encode_better.go
+++ b/vendor/github.com/klauspost/compress/s2/encode_better.go
@@ -157,7 +157,6 @@ func encodeBlockBetterGo(dst, src []byte) (d int) {
index0 := base + 1
index1 := s - 2
- cv = load64(src, s)
for index0 < index1 {
cv0 := load64(src, index0)
cv1 := load64(src, index1)
@@ -269,18 +268,21 @@ func encodeBlockBetterGo(dst, src []byte) (d int) {
lTable[hash7(cv0, lTableBits)] = uint32(index0)
sTable[hash4(cv0>>8, sTableBits)] = uint32(index0 + 1)
+ // lTable could be postponed, but very minor difference.
lTable[hash7(cv1, lTableBits)] = uint32(index1)
sTable[hash4(cv1>>8, sTableBits)] = uint32(index1 + 1)
index0 += 1
index1 -= 1
cv = load64(src, s)
- // index every second long in between.
- for index0 < index1 {
+ // Index large values sparsely in between.
+ // We do two starting from different offsets for speed.
+ index2 := (index0 + index1 + 1) >> 1
+ for index2 < index1 {
lTable[hash7(load64(src, index0), lTableBits)] = uint32(index0)
- lTable[hash7(load64(src, index1), lTableBits)] = uint32(index1)
+ lTable[hash7(load64(src, index2), lTableBits)] = uint32(index2)
index0 += 2
- index1 -= 2
+ index2 += 2
}
}
@@ -459,12 +461,14 @@ func encodeBlockBetterSnappyGo(dst, src []byte) (d int) {
index1 -= 1
cv = load64(src, s)
- // index every second long in between.
- for index0 < index1 {
+ // Index large values sparsely in between.
+ // We do two starting from different offsets for speed.
+ index2 := (index0 + index1 + 1) >> 1
+ for index2 < index1 {
lTable[hash7(load64(src, index0), lTableBits)] = uint32(index0)
- lTable[hash7(load64(src, index1), lTableBits)] = uint32(index1)
+ lTable[hash7(load64(src, index2), lTableBits)] = uint32(index2)
index0 += 2
- index1 -= 2
+ index2 += 2
}
}
@@ -599,7 +603,6 @@ searchDict:
if s >= sLimit {
break searchDict
}
- cv = load64(src, s)
// Index in-between
index0 := base + 1
index1 := s - 2
@@ -865,12 +868,14 @@ searchDict:
index1 -= 1
cv = load64(src, s)
- // index every second long in between.
- for index0 < index1 {
+ // Index large values sparsely in between.
+ // We do two starting from different offsets for speed.
+ index2 := (index0 + index1 + 1) >> 1
+ for index2 < index1 {
lTable[hash7(load64(src, index0), lTableBits)] = uint32(index0)
- lTable[hash7(load64(src, index1), lTableBits)] = uint32(index1)
+ lTable[hash7(load64(src, index2), lTableBits)] = uint32(index2)
index0 += 2
- index1 -= 2
+ index2 += 2
}
}
@@ -961,7 +966,6 @@ searchDict:
index0 := base + 1
index1 := s - 2
- cv = load64(src, s)
for index0 < index1 {
cv0 := load64(src, index0)
cv1 := load64(src, index1)
@@ -1079,12 +1083,14 @@ searchDict:
index1 -= 1
cv = load64(src, s)
- // index every second long in between.
- for index0 < index1 {
+ // Index large values sparsely in between.
+ // We do two starting from different offsets for speed.
+ index2 := (index0 + index1 + 1) >> 1
+ for index2 < index1 {
lTable[hash7(load64(src, index0), lTableBits)] = uint32(index0)
- lTable[hash7(load64(src, index1), lTableBits)] = uint32(index1)
+ lTable[hash7(load64(src, index2), lTableBits)] = uint32(index2)
index0 += 2
- index1 -= 2
+ index2 += 2
}
}