]> Cypherpunks.ru repositories - gostls13.git/commitdiff
hash/maphash: move bytes/hash to hash/maphash
authorKeith Randall <keithr@alum.mit.edu>
Sat, 2 Nov 2019 17:22:18 +0000 (10:22 -0700)
committerKeith Randall <khr@golang.org>
Sat, 2 Nov 2019 18:30:37 +0000 (18:30 +0000)
Fixes #34778

Change-Id: If8225a7c41cb2af3f67157fb9670eef86272e85e
Reviewed-on: https://go-review.googlesource.com/c/go/+/204997
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/go/build/deps_test.go
src/hash/maphash/maphash.go [moved from src/bytes/hash/hash.go with 97% similarity]
src/hash/maphash/maphash_test.go [moved from src/bytes/hash/hash_test.go with 83% similarity]
src/hash/maphash/smhasher_test.go [moved from src/bytes/hash/smhasher_test.go with 98% similarity]

index 6443094515da8222ac0d300d14120722ed5ca646..2ef90a977e1c2627a400ab45fc49639f8e4e53f8 100644 (file)
@@ -84,18 +84,16 @@ var pkgDeps = map[string][]string{
        },
 
        // L2 adds Unicode and strings processing.
-       "bufio":      {"L0", "unicode/utf8", "bytes"},
-       "bytes":      {"L0", "unicode", "unicode/utf8"},
-       "bytes/hash": {"L0"},
-       "path":       {"L0", "unicode/utf8", "strings"},
-       "strings":    {"L0", "unicode", "unicode/utf8"},
-       "unicode":    {},
+       "bufio":   {"L0", "unicode/utf8", "bytes"},
+       "bytes":   {"L0", "unicode", "unicode/utf8"},
+       "path":    {"L0", "unicode/utf8", "strings"},
+       "strings": {"L0", "unicode", "unicode/utf8"},
+       "unicode": {},
 
        "L2": {
                "L1",
                "bufio",
                "bytes",
-               "bytes/hash",
                "path",
                "strings",
                "unicode",
@@ -116,6 +114,7 @@ var pkgDeps = map[string][]string{
        "hash/crc32":             {"L2", "hash"},
        "hash/crc64":             {"L2", "hash"},
        "hash/fnv":               {"L2", "hash"},
+       "hash/maphash":           {"L2", "hash"},
        "image":                  {"L2", "image/color"}, // interfaces
        "image/color":            {"L2"},                // interfaces
        "image/color/palette":    {"L2", "image/color"},
@@ -244,51 +243,51 @@ var pkgDeps = map[string][]string{
        "go/types":                  {"L4", "GOPARSER", "container/heap", "go/constant"},
 
        // One of a kind.
-       "archive/tar":                    {"L4", "OS", "syscall", "os/user"},
-       "archive/zip":                    {"L4", "OS", "compress/flate"},
-       "container/heap":                 {"sort"},
-       "compress/bzip2":                 {"L4"},
-       "compress/flate":                 {"L4"},
-       "compress/gzip":                  {"L4", "compress/flate"},
-       "compress/lzw":                   {"L4"},
-       "compress/zlib":                  {"L4", "compress/flate"},
-       "context":                        {"errors", "internal/reflectlite", "sync", "sync/atomic", "time"},
-       "database/sql":                   {"L4", "container/list", "context", "database/sql/driver", "database/sql/internal"},
-       "database/sql/driver":            {"L4", "context", "time", "database/sql/internal"},
-       "debug/dwarf":                    {"L4"},
-       "debug/elf":                      {"L4", "OS", "debug/dwarf", "compress/zlib"},
-       "debug/gosym":                    {"L4"},
-       "debug/macho":                    {"L4", "OS", "debug/dwarf", "compress/zlib"},
-       "debug/pe":                       {"L4", "OS", "debug/dwarf", "compress/zlib"},
-       "debug/plan9obj":                 {"L4", "OS"},
-       "encoding":                       {"L4"},
-       "encoding/ascii85":               {"L4"},
-       "encoding/asn1":                  {"L4", "math/big"},
-       "encoding/csv":                   {"L4"},
-       "encoding/gob":                   {"L4", "OS", "encoding"},
-       "encoding/hex":                   {"L4"},
-       "encoding/json":                  {"L4", "encoding"},
-       "encoding/pem":                   {"L4"},
-       "encoding/xml":                   {"L4", "encoding"},
-       "flag":                           {"L4", "OS"},
-       "go/build":                       {"L4", "OS", "GOPARSER", "internal/goroot", "internal/goversion"},
-       "html":                           {"L4"},
-       "image/draw":                     {"L4", "image/internal/imageutil"},
-       "image/gif":                      {"L4", "compress/lzw", "image/color/palette", "image/draw"},
-       "image/internal/imageutil":       {"L4"},
-       "image/jpeg":                     {"L4", "image/internal/imageutil"},
-       "image/png":                      {"L4", "compress/zlib"},
-       "index/suffixarray":              {"L4", "regexp"},
-       "internal/goroot":                {"L4", "OS"},
-       "internal/singleflight":          {"sync"},
-       "internal/trace":                 {"L4", "OS", "container/heap"},
-       "internal/xcoff":                 {"L4", "OS", "debug/dwarf"},
-       "math/big":                       {"L4"},
-       "mime":                           {"L4", "OS", "syscall", "internal/syscall/windows/registry"},
-       "mime/quotedprintable":           {"L4"},
-       "net/internal/socktest":          {"L4", "OS", "syscall", "internal/syscall/windows"},
-       "net/url":                        {"L4"},
-       "plugin":                         {"L0", "OS", "CGO"},
+       "archive/tar":              {"L4", "OS", "syscall", "os/user"},
+       "archive/zip":              {"L4", "OS", "compress/flate"},
+       "container/heap":           {"sort"},
+       "compress/bzip2":           {"L4"},
+       "compress/flate":           {"L4"},
+       "compress/gzip":            {"L4", "compress/flate"},
+       "compress/lzw":             {"L4"},
+       "compress/zlib":            {"L4", "compress/flate"},
+       "context":                  {"errors", "internal/reflectlite", "sync", "sync/atomic", "time"},
+       "database/sql":             {"L4", "container/list", "context", "database/sql/driver", "database/sql/internal"},
+       "database/sql/driver":      {"L4", "context", "time", "database/sql/internal"},
+       "debug/dwarf":              {"L4"},
+       "debug/elf":                {"L4", "OS", "debug/dwarf", "compress/zlib"},
+       "debug/gosym":              {"L4"},
+       "debug/macho":              {"L4", "OS", "debug/dwarf", "compress/zlib"},
+       "debug/pe":                 {"L4", "OS", "debug/dwarf", "compress/zlib"},
+       "debug/plan9obj":           {"L4", "OS"},
+       "encoding":                 {"L4"},
+       "encoding/ascii85":         {"L4"},
+       "encoding/asn1":            {"L4", "math/big"},
+       "encoding/csv":             {"L4"},
+       "encoding/gob":             {"L4", "OS", "encoding"},
+       "encoding/hex":             {"L4"},
+       "encoding/json":            {"L4", "encoding"},
+       "encoding/pem":             {"L4"},
+       "encoding/xml":             {"L4", "encoding"},
+       "flag":                     {"L4", "OS"},
+       "go/build":                 {"L4", "OS", "GOPARSER", "internal/goroot", "internal/goversion"},
+       "html":                     {"L4"},
+       "image/draw":               {"L4", "image/internal/imageutil"},
+       "image/gif":                {"L4", "compress/lzw", "image/color/palette", "image/draw"},
+       "image/internal/imageutil": {"L4"},
+       "image/jpeg":               {"L4", "image/internal/imageutil"},
+       "image/png":                {"L4", "compress/zlib"},
+       "index/suffixarray":        {"L4", "regexp"},
+       "internal/goroot":          {"L4", "OS"},
+       "internal/singleflight":    {"sync"},
+       "internal/trace":           {"L4", "OS", "container/heap"},
+       "internal/xcoff":           {"L4", "OS", "debug/dwarf"},
+       "math/big":                 {"L4"},
+       "mime":                     {"L4", "OS", "syscall", "internal/syscall/windows/registry"},
+       "mime/quotedprintable":     {"L4"},
+       "net/internal/socktest":    {"L4", "OS", "syscall", "internal/syscall/windows"},
+       "net/url":                  {"L4"},
+       "plugin":                   {"L0", "OS", "CGO"},
        "runtime/pprof/internal/profile": {"L4", "OS", "compress/gzip", "regexp"},
        "testing/internal/testdeps":      {"L4", "internal/testlog", "runtime/pprof", "regexp"},
        "text/scanner":                   {"L4", "OS"},
similarity index 97%
rename from src/bytes/hash/hash.go
rename to src/hash/maphash/maphash.go
index cc78b229019e879bb6e2943baa47654c6261de70..0cd4769c03762c68698ea84a1b4f8a3c0e6e2e75 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Package bytes/hash provides hash functions on byte sequences. These
+// Package hash/maphash provides hash functions on byte sequences. These
 // hash functions are intended to be used to implement hash tables or
 // other data structures that need to map arbitrary strings or byte
 // sequences to a uniform distribution of integers. The hash functions
@@ -29,7 +29,7 @@
 // All bits of the Hash result are close to uniformly and
 // independently distributed, so can be safely restricted to a range
 // using bit masking, shifting, or modular arithmetic.
-package hash
+package maphash
 
 import (
        "unsafe"
@@ -161,7 +161,7 @@ func rthash(b []byte, seed uint64) uint64 {
 //go:linkname runtime_memhash runtime.memhash
 func runtime_memhash(p unsafe.Pointer, seed, s uintptr) uintptr
 
-// Wrapper functions so that a bytes/hash.Hash implements
+// Wrapper functions so that a hash/maphash.Hash implements
 // the hash.Hash and hash.Hash64 interfaces.
 
 func (h *Hash) Write(b []byte) (int, error) {
similarity index 83%
rename from src/bytes/hash/hash_test.go
rename to src/hash/maphash/maphash_test.go
index f36d5068310fc7c4e2d09901c3b3d3d46bc2455e..f9f631212bce6b9e2df14085e0ecfa124a974cf9 100644 (file)
@@ -2,18 +2,18 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package hash_test
+package maphash_test
 
 import (
-       "bytes/hash"
-       basehash "hash"
+       "hash"
+       "hash/maphash"
        "testing"
 )
 
 func TestUnseededHash(t *testing.T) {
        m := map[uint64]struct{}{}
        for i := 0; i < 1000; i++ {
-               h := hash.New()
+               h := maphash.New()
                m[h.Hash()] = struct{}{}
        }
        if len(m) < 900 {
@@ -22,10 +22,10 @@ func TestUnseededHash(t *testing.T) {
 }
 
 func TestSeededHash(t *testing.T) {
-       s := hash.MakeSeed(1234)
+       s := maphash.MakeSeed(1234)
        m := map[uint64]struct{}{}
        for i := 0; i < 1000; i++ {
-               h := hash.New()
+               h := maphash.New()
                h.SetSeed(s)
                m[h.Hash()] = struct{}{}
        }
@@ -36,8 +36,8 @@ func TestSeededHash(t *testing.T) {
 
 func TestHashGrouping(t *testing.T) {
        b := []byte("foo")
-       h1 := hash.New()
-       h2 := hash.New()
+       h1 := maphash.New()
+       h2 := maphash.New()
        h2.SetSeed(h1.Seed())
        h1.AddBytes(b)
        for _, x := range b {
@@ -51,8 +51,8 @@ func TestHashGrouping(t *testing.T) {
 func TestHashBytesVsString(t *testing.T) {
        s := "foo"
        b := []byte(s)
-       h1 := hash.New()
-       h2 := hash.New()
+       h1 := maphash.New()
+       h2 := maphash.New()
        h2.SetSeed(h1.Seed())
        h1.AddString(s)
        h2.AddBytes(b)
@@ -66,7 +66,7 @@ func TestHashHighBytes(t *testing.T) {
        const N = 10
        m := map[uint64]struct{}{}
        for i := 0; i < N; i++ {
-               h := hash.New()
+               h := maphash.New()
                h.AddString("foo")
                m[h.Hash()>>32] = struct{}{}
        }
@@ -76,5 +76,5 @@ func TestHashHighBytes(t *testing.T) {
 }
 
 // Make sure a Hash implements the hash.Hash and hash.Hash64 interfaces.
-var _ basehash.Hash = &hash.Hash{}
-var _ basehash.Hash64 = &hash.Hash{}
+var _ hash.Hash = &maphash.Hash{}
+var _ hash.Hash64 = &maphash.Hash{}
similarity index 98%
rename from src/bytes/hash/smhasher_test.go
rename to src/hash/maphash/smhasher_test.go
index f5169ffa27d58cfe459145cb1e60abd24ccb13f0..4ac3d589769c3f8d774feaf289c7a733fdbb6a0e 100644 (file)
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package hash_test
+package maphash_test
 
 import (
-       "bytes/hash"
        "fmt"
+       "hash/maphash"
        "math"
        "math/rand"
        "runtime"
@@ -45,14 +45,14 @@ func TestSmhasherSanity(t *testing.T) {
 }
 
 func bytesHash(b []byte, seed uint64) uint64 {
-       h := hash.New()
-       h.SetSeed(hash.MakeSeed(seed))
+       h := maphash.New()
+       h.SetSeed(maphash.MakeSeed(seed))
        h.AddBytes(b)
        return h.Hash()
 }
 func stringHash(s string, seed uint64) uint64 {
-       h := hash.New()
-       h.SetSeed(hash.MakeSeed(seed))
+       h := maphash.New()
+       h.SetSeed(maphash.MakeSeed(seed))
        h.AddString(s)
        return h.Hash()
 }