aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hash/maphash/maphash.go24
-rw-r--r--src/hash/maphash/maphash_purego.go23
2 files changed, 23 insertions, 24 deletions
diff --git a/src/hash/maphash/maphash.go b/src/hash/maphash/maphash.go
index d328cd3929..c6f3e62b5d 100644
--- a/src/hash/maphash/maphash.go
+++ b/src/hash/maphash/maphash.go
@@ -15,8 +15,6 @@ package maphash
import (
"hash"
"internal/abi"
- "internal/byteorder"
- "math"
)
// A Seed is a random value that selects the specific hash function
@@ -310,25 +308,3 @@ func WriteComparable[T comparable](h *Hash, x T) {
}
writeComparable(h, x)
}
-
-func (h *Hash) float64(f float64) {
- if f == 0 {
- h.WriteByte(0)
- return
- }
- var buf [8]byte
- if f != f {
- byteorder.LEPutUint64(buf[:], randUint64())
- h.Write(buf[:])
- return
- }
- byteorder.LEPutUint64(buf[:], math.Float64bits(f))
- h.Write(buf[:])
-}
-
-func btoi(b bool) byte {
- if b {
- return 1
- }
- return 0
-}
diff --git a/src/hash/maphash/maphash_purego.go b/src/hash/maphash/maphash_purego.go
index 07b5eaa460..e286c5a5aa 100644
--- a/src/hash/maphash/maphash_purego.go
+++ b/src/hash/maphash/maphash_purego.go
@@ -10,6 +10,7 @@ import (
"crypto/rand"
"errors"
"internal/byteorder"
+ "math"
"math/bits"
"reflect"
)
@@ -175,3 +176,25 @@ func appendT(h *Hash, v reflect.Value) {
}
panic(errors.New("maphash: hash of unhashable type " + v.Type().String()))
}
+
+func (h *Hash) float64(f float64) {
+ if f == 0 {
+ h.WriteByte(0)
+ return
+ }
+ var buf [8]byte
+ if f != f {
+ byteorder.LEPutUint64(buf[:], randUint64())
+ h.Write(buf[:])
+ return
+ }
+ byteorder.LEPutUint64(buf[:], math.Float64bits(f))
+ h.Write(buf[:])
+}
+
+func btoi(b bool) byte {
+ if b {
+ return 1
+ }
+ return 0
+}