From 4b7a62a41deddd75d8971c62cfaffb14a417dffa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:12:15 +0000 Subject: [PATCH] Bump github.com/segmentio/fasthash Bumps [github.com/segmentio/fasthash](https://github.com/segmentio/fasthash) from 0.0.0-20180216231524-a72b379d632e to 1.0.3. - [Commits](https://github.com/segmentio/fasthash/commits/v1.0.3) --- updated-dependencies: - dependency-name: github.com/segmentio/fasthash dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +- .../segmentio/fasthash/fnv1a/hash.go | 80 +++++++++++++---- .../segmentio/fasthash/fnv1a/hash32.go | 85 +++++++++++++++---- vendor/modules.txt | 4 +- 5 files changed, 138 insertions(+), 37 deletions(-) diff --git a/go.mod b/go.mod index c69418a3dbd..c326a5ec069 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( github.com/prometheus/common v0.55.0 github.com/prometheus/prometheus v0.54.0 github.com/prometheus/statsd_exporter v0.26.0 - github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e + github.com/segmentio/fasthash v1.0.3 github.com/sony/gobreaker v0.4.1 github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index b6602d7172c..75c661ca1bd 100644 --- a/go.sum +++ b/go.sum @@ -825,8 +825,8 @@ github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29 h1:BkTk4gynLjguayxrYxZoMZjBnA github.com/scaleway/scaleway-sdk-go v1.0.0-beta.29/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e h1:uO75wNGioszjmIzcY/tvdDYKRLVvzggtAmmJkn9j4GQ= -github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e/go.mod h1:tm/wZFQ8e24NYaBGIlnO2WGCAi67re4HHuOm0sftE/M= +github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM= +github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= github.com/sercand/kuberesolver/v5 v5.1.1 h1:CYH+d67G0sGBj7q5wLK61yzqJJ8gLLC8aeprPTHb6yY= github.com/sercand/kuberesolver/v5 v5.1.1/go.mod h1:Fs1KbKhVRnB2aDWN12NjKCB+RgYMWZJ294T3BtmVCpQ= github.com/shirou/gopsutil/v3 v3.24.4 h1:dEHgzZXt4LMNm+oYELpzl9YCqV65Yr/6SfrvgRBtXeU= diff --git a/vendor/github.com/segmentio/fasthash/fnv1a/hash.go b/vendor/github.com/segmentio/fasthash/fnv1a/hash.go index d2f3c966844..92849b1142b 100644 --- a/vendor/github.com/segmentio/fasthash/fnv1a/hash.go +++ b/vendor/github.com/segmentio/fasthash/fnv1a/hash.go @@ -14,6 +14,11 @@ func HashString64(s string) uint64 { return AddString64(Init64, s) } +// HashBytes64 returns the hash of u. +func HashBytes64(b []byte) uint64 { + return AddBytes64(Init64, b) +} + // HashUint64 returns the hash of u. func HashUint64(u uint64) uint64 { return AddUint64(Init64, u) @@ -34,24 +39,69 @@ func AddString64(h uint64, s string) uint64 { - BenchmarkHash64/hash_function-4 50000000 38.6 ns/op 932.35 MB/s 0 B/op 0 allocs/op */ + for len(s) >= 8 { + h = (h ^ uint64(s[0])) * prime64 + h = (h ^ uint64(s[1])) * prime64 + h = (h ^ uint64(s[2])) * prime64 + h = (h ^ uint64(s[3])) * prime64 + h = (h ^ uint64(s[4])) * prime64 + h = (h ^ uint64(s[5])) * prime64 + h = (h ^ uint64(s[6])) * prime64 + h = (h ^ uint64(s[7])) * prime64 + s = s[8:] + } + + if len(s) >= 4 { + h = (h ^ uint64(s[0])) * prime64 + h = (h ^ uint64(s[1])) * prime64 + h = (h ^ uint64(s[2])) * prime64 + h = (h ^ uint64(s[3])) * prime64 + s = s[4:] + } + + if len(s) >= 2 { + h = (h ^ uint64(s[0])) * prime64 + h = (h ^ uint64(s[1])) * prime64 + s = s[2:] + } + + if len(s) > 0 { + h = (h ^ uint64(s[0])) * prime64 + } + + return h +} + +// AddBytes64 adds the hash of b to the precomputed hash value h. +func AddBytes64(h uint64, b []byte) uint64 { + for len(b) >= 8 { + h = (h ^ uint64(b[0])) * prime64 + h = (h ^ uint64(b[1])) * prime64 + h = (h ^ uint64(b[2])) * prime64 + h = (h ^ uint64(b[3])) * prime64 + h = (h ^ uint64(b[4])) * prime64 + h = (h ^ uint64(b[5])) * prime64 + h = (h ^ uint64(b[6])) * prime64 + h = (h ^ uint64(b[7])) * prime64 + b = b[8:] + } + + if len(b) >= 4 { + h = (h ^ uint64(b[0])) * prime64 + h = (h ^ uint64(b[1])) * prime64 + h = (h ^ uint64(b[2])) * prime64 + h = (h ^ uint64(b[3])) * prime64 + b = b[4:] + } - i := 0 - n := (len(s) / 8) * 8 - - for i != n { - h = (h ^ uint64(s[i])) * prime64 - h = (h ^ uint64(s[i+1])) * prime64 - h = (h ^ uint64(s[i+2])) * prime64 - h = (h ^ uint64(s[i+3])) * prime64 - h = (h ^ uint64(s[i+4])) * prime64 - h = (h ^ uint64(s[i+5])) * prime64 - h = (h ^ uint64(s[i+6])) * prime64 - h = (h ^ uint64(s[i+7])) * prime64 - i += 8 + if len(b) >= 2 { + h = (h ^ uint64(b[0])) * prime64 + h = (h ^ uint64(b[1])) * prime64 + b = b[2:] } - for _, c := range s[i:] { - h = (h ^ uint64(c)) * prime64 + if len(b) > 0 { + h = (h ^ uint64(b[0])) * prime64 } return h diff --git a/vendor/github.com/segmentio/fasthash/fnv1a/hash32.go b/vendor/github.com/segmentio/fasthash/fnv1a/hash32.go index df1f3e5b07f..ac91e247034 100644 --- a/vendor/github.com/segmentio/fasthash/fnv1a/hash32.go +++ b/vendor/github.com/segmentio/fasthash/fnv1a/hash32.go @@ -14,6 +14,11 @@ func HashString32(s string) uint32 { return AddString32(Init32, s) } +// HashBytes32 returns the hash of u. +func HashBytes32(b []byte) uint32 { + return AddBytes32(Init32, b) +} + // HashUint32 returns the hash of u. func HashUint32(u uint32) uint32 { return AddUint32(Init32, u) @@ -21,23 +26,69 @@ func HashUint32(u uint32) uint32 { // AddString32 adds the hash of s to the precomputed hash value h. func AddString32(h uint32, s string) uint32 { - i := 0 - n := (len(s) / 8) * 8 - - for i != n { - h = (h ^ uint32(s[i])) * prime32 - h = (h ^ uint32(s[i+1])) * prime32 - h = (h ^ uint32(s[i+2])) * prime32 - h = (h ^ uint32(s[i+3])) * prime32 - h = (h ^ uint32(s[i+4])) * prime32 - h = (h ^ uint32(s[i+5])) * prime32 - h = (h ^ uint32(s[i+6])) * prime32 - h = (h ^ uint32(s[i+7])) * prime32 - i += 8 - } - - for _, c := range s[i:] { - h = (h ^ uint32(c)) * prime32 + for len(s) >= 8 { + h = (h ^ uint32(s[0])) * prime32 + h = (h ^ uint32(s[1])) * prime32 + h = (h ^ uint32(s[2])) * prime32 + h = (h ^ uint32(s[3])) * prime32 + h = (h ^ uint32(s[4])) * prime32 + h = (h ^ uint32(s[5])) * prime32 + h = (h ^ uint32(s[6])) * prime32 + h = (h ^ uint32(s[7])) * prime32 + s = s[8:] + } + + if len(s) >= 4 { + h = (h ^ uint32(s[0])) * prime32 + h = (h ^ uint32(s[1])) * prime32 + h = (h ^ uint32(s[2])) * prime32 + h = (h ^ uint32(s[3])) * prime32 + s = s[4:] + } + + if len(s) >= 2 { + h = (h ^ uint32(s[0])) * prime32 + h = (h ^ uint32(s[1])) * prime32 + s = s[2:] + } + + if len(s) > 0 { + h = (h ^ uint32(s[0])) * prime32 + } + + return h +} + +// AddBytes32 adds the hash of b to the precomputed hash value h. +func AddBytes32(h uint32, b []byte) uint32 { + for len(b) >= 8 { + h = (h ^ uint32(b[0])) * prime32 + h = (h ^ uint32(b[1])) * prime32 + h = (h ^ uint32(b[2])) * prime32 + h = (h ^ uint32(b[3])) * prime32 + h = (h ^ uint32(b[4])) * prime32 + h = (h ^ uint32(b[5])) * prime32 + h = (h ^ uint32(b[6])) * prime32 + h = (h ^ uint32(b[7])) * prime32 + b = b[8:] + } + + if len(b) >= 4 { + h = (h ^ uint32(b[0])) * prime32 + h = (h ^ uint32(b[1])) * prime32 + h = (h ^ uint32(b[2])) * prime32 + h = (h ^ uint32(b[3])) * prime32 + b = b[4:] + } + + if len(b) >= 2 { + h = (h ^ uint32(b[0])) * prime32 + h = (h ^ uint32(b[1])) * prime32 + b = b[2:] + } + + if len(b) > 0 { + h = (h ^ uint32(b[0])) * prime32 } return h diff --git a/vendor/modules.txt b/vendor/modules.txt index 2d25b64a34b..e87a0c040a2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1158,8 +1158,8 @@ github.com/sagikazarmark/slog-shim # github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 ## explicit github.com/sean-/seed -# github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e -## explicit +# github.com/segmentio/fasthash v1.0.3 +## explicit; go 1.11 github.com/segmentio/fasthash/fnv1a # github.com/sercand/kuberesolver/v5 v5.1.1 ## explicit; go 1.18