From b1f29b2d443f5c8df15d6702937ae786660375be Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Sat, 27 Dec 2014 20:32:11 -0800 Subject: [PATCH] runtime: get rid of goalg, no longer needed The goalg function was a holdover from when we had algorithm tables in both C and Go. It is no longer needed. Change-Id: Ia0c1af35bef3497a899f22084a1a7b42daae72a0 Reviewed-on: https://go-review.googlesource.com/2099 Reviewed-by: Brad Fitzpatrick --- src/reflect/type.go | 3 ++- src/runtime/alg.go | 13 ++++--------- src/runtime/hashmap.go | 16 ++++++++-------- src/runtime/hashmap_fast.go | 12 ++++++------ src/runtime/type.go | 2 +- 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/reflect/type.go b/src/reflect/type.go index b54e60adaa..75d73adbca 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -251,7 +251,7 @@ type rtype struct { align uint8 // alignment of variable with this type fieldAlign uint8 // alignment of struct field with this type kind uint8 // enumeration for C - alg *typeAlg // algorithm table (../runtime/runtime.h:/Alg) + alg *typeAlg // algorithm table gc [2]unsafe.Pointer // garbage collection data string *string // string form; unnecessary but undeniably useful *uncommonType // (relatively) uncommon fields @@ -259,6 +259,7 @@ type rtype struct { zero unsafe.Pointer // pointer to zero value } +// a copy of runtime.typeAlg type typeAlg struct { // function for hashing objects of this type // (ptr to object, size, seed) -> hash diff --git a/src/runtime/alg.go b/src/runtime/alg.go index 1bed3c461b..15e3abe368 100644 --- a/src/runtime/alg.go +++ b/src/runtime/alg.go @@ -131,7 +131,7 @@ func interhash(p unsafe.Pointer, s, h uintptr) uintptr { return h } t := tab._type - fn := goalg(t.alg).hash + fn := t.alg.hash if fn == nil { panic(errorString("hash of unhashable type " + *t._string)) } @@ -148,7 +148,7 @@ func nilinterhash(p unsafe.Pointer, s, h uintptr) uintptr { if t == nil { return h } - fn := goalg(t.alg).hash + fn := t.alg.hash if fn == nil { panic(errorString("hash of unhashable type " + *t._string)) } @@ -219,7 +219,7 @@ func efaceeq(p, q interface{}) bool { if t == nil { return true } - eq := goalg(t.alg).equal + eq := t.alg.equal if eq == nil { panic(errorString("comparing uncomparable type " + *t._string)) } @@ -241,7 +241,7 @@ func ifaceeq(p, q interface { return true } t := xtab._type - eq := goalg(t.alg).equal + eq := t.alg.equal if eq == nil { panic(errorString("comparing uncomparable type " + *t._string)) } @@ -285,11 +285,6 @@ func memclrBytes(b []byte) { memclr(s.array, uintptr(s.len)) } -// TODO(dvyukov): remove when Type is converted to Go and contains *typeAlg. -func goalg(a unsafe.Pointer) *typeAlg { - return (*typeAlg)(a) -} - // used in asm_{386,amd64}.s const hashRandomBytes = ptrSize / 4 * 64 diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go index f0759b58a9..999270a3b1 100644 --- a/src/runtime/hashmap.go +++ b/src/runtime/hashmap.go @@ -251,7 +251,7 @@ func mapaccess1(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer { if h == nil || h.count == 0 { return unsafe.Pointer(t.elem.zero) } - alg := goalg(t.key.alg) + alg := t.key.alg hash := alg.hash(key, uintptr(t.key.size), uintptr(h.hash0)) m := uintptr(1)<