]> Cypherpunks repositories - gostls13.git/commitdiff
maps: move test funcs to maps_test.go
authorTobias Klauser <tklauser@distanz.ch>
Wed, 24 May 2023 10:28:25 +0000 (12:28 +0200)
committerGopher Robot <gobot@golang.org>
Wed, 24 May 2023 21:17:23 +0000 (21:17 +0000)
keysForBenchmarking and valuesForBenchmarking are only used in benchmark
tests.

Change-Id: Ie4fcb81e0470cc8627b395644787429b79952538
Reviewed-on: https://go-review.googlesource.com/c/go/+/497380
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

src/maps/maps.go
src/maps/maps_test.go

index 15ec456a172a515ce7cb616602bfc64194a276bd..4dabb7caa33171205f3b6633aae024285ea0742a 100644 (file)
@@ -20,10 +20,6 @@ func Keys[M ~map[K]V, K comparable, V any](m M) []K {
        return r
 }
 
-func keysForBenchmarking[M ~map[K]V, K comparable, V any](m M, s []K) {
-       keys(m, unsafe.Pointer(&s))
-}
-
 // values is implemented in the runtime package.
 //
 //go:noescape
@@ -37,10 +33,6 @@ func Values[M ~map[K]V, K comparable, V any](m M) []V {
        return r
 }
 
-func valuesForBenchmarking[M ~map[K]V, K comparable, V any](m M, s []V) {
-       values(m, unsafe.Pointer(&s))
-}
-
 // Equal reports whether two maps contain the same key/value pairs.
 // Values are compared using ==.
 func Equal[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool {
index 6b92e0d8d6cd883f8723f53d73635daf4eb2880a..dc803e2dbc2826d68ff73e1ca0fdcaade581a524 100644 (file)
@@ -10,11 +10,16 @@ import (
        "sort"
        "strconv"
        "testing"
+       "unsafe"
 )
 
 var m1 = map[int]int{1: 2, 2: 4, 4: 8, 8: 16}
 var m2 = map[int]string{1: "2", 2: "4", 4: "8", 8: "16"}
 
+func keysForBenchmarking[M ~map[K]V, K comparable, V any](m M, s []K) {
+       keys(m, unsafe.Pointer(&s))
+}
+
 func TestKeys(t *testing.T) {
        want := []int{1, 2, 4, 8}
 
@@ -48,6 +53,10 @@ func TestKeys(t *testing.T) {
        }
 }
 
+func valuesForBenchmarking[M ~map[K]V, K comparable, V any](m M, s []V) {
+       values(m, unsafe.Pointer(&s))
+}
+
 func TestValues(t *testing.T) {
        got1 := Values(m1)
        want1 := []int{2, 4, 8, 16}