gob: compute information about a user's type once.

Other than maybe cleaning the code up a bit, this has
little practical effect for now, but lays the foundation
for remembering the method set of a type, which can
be expensive.

R=rsc
CC=golang-dev
https://golang.org/cl/4193041
This commit is contained in:
Rob Pike 2011-02-22 12:31:57 -08:00
parent 556506e869
commit 14b6a47748
5 changed files with 101 additions and 57 deletions

View file

@ -984,7 +984,7 @@ func TestInvalidField(t *testing.T) {
var bad0 Bad0
bad0.ch = make(chan int)
b := new(bytes.Buffer)
err := nilEncoder.encode(b, reflect.NewValue(&bad0))
err := nilEncoder.encode(b, reflect.NewValue(&bad0), userType(reflect.Typeof(&bad0)))
if err == nil {
t.Error("expected error; got none")
} else if strings.Index(err.String(), "type") < 0 {