From 8e8d280a1d7ef66a5f74c7913f369bd7e4e7301f Mon Sep 17 00:00:00 2001 From: binbin Date: Mon, 15 Nov 2021 13:42:48 +0800 Subject: [PATCH] commit --- codec.go | 7 ------- encode.go | 6 +----- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/codec.go b/codec.go index cb2c5908..5087efa5 100644 --- a/codec.go +++ b/codec.go @@ -476,10 +476,3 @@ func ConvertSliceValueType(destTyp reflect.Type, v reflect.Value) (reflect.Value return sl, nil } - -// PackPtrInterface pack interface struct to get the interface pointer -func PackPtrInterface(s interface{}, value reflect.Value) interface{} { - vp := reflect.New(reflect.TypeOf(s)) - vp.Elem().Set(value) - return vp.Interface() -} diff --git a/encode.go b/encode.go index 0daf3e05..c26832e9 100644 --- a/encode.go +++ b/encode.go @@ -160,11 +160,7 @@ func (e *Encoder) Encode(v interface{}) error { switch t.Kind() { case reflect.Struct: vv := reflect.ValueOf(v) - if vv.Kind() != reflect.Ptr { - v = PackPtrInterface(v, vv) - } else { - vv = UnpackPtr(vv) - } + vv = UnpackPtr(vv) if !vv.IsValid() { e.buffer = EncNull(e.buffer) return nil