diff options
-rw-r--r-- | libgo/go/reflect/value.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libgo/go/reflect/value.go b/libgo/go/reflect/value.go index c390b8e..c36e995 100644 --- a/libgo/go/reflect/value.go +++ b/libgo/go/reflect/value.go @@ -1405,9 +1405,9 @@ func (v Value) send(x Value, nb bool) (selected bool) { func (v Value) Set(x Value) { v.mustBeAssignable() x.mustBeExported() // do not let unexported x leak - var target *interface{} + var target unsafe.Pointer if v.kind() == Interface { - target = (*interface{})(v.ptr) + target = v.ptr } x = x.assignTo("reflect.Set", v.typ, target) if x.flag&flagIndir != 0 { @@ -2230,7 +2230,7 @@ func NewAt(typ Type, p unsafe.Pointer) Value { // assignTo returns a value v that can be assigned directly to typ. // It panics if v is not assignable to typ. // For a conversion to an interface type, target is a suggested scratch space to use. -func (v Value) assignTo(context string, dst *rtype, target *interface{}) Value { +func (v Value) assignTo(context string, dst *rtype, target unsafe.Pointer) Value { if v.flag&flagMethod != 0 { v = makeMethodValue(context, v) } @@ -2246,15 +2246,15 @@ func (v Value) assignTo(context string, dst *rtype, target *interface{}) Value { case implements(dst, v.typ): if target == nil { - target = new(interface{}) + target = unsafe_New(dst) } x := valueInterface(v, false) if dst.NumMethod() == 0 { - *target = x + *(*interface{})(target) = x } else { - ifaceE2I(dst, x, unsafe.Pointer(target)) + ifaceE2I(dst, x, target) } - return Value{dst, unsafe.Pointer(target) /* 0, */, flagIndir | flag(Interface)<<flagKindShift} + return Value{dst, target /* 0, */, flagIndir | flag(Interface)<<flagKindShift} } // Failed. @@ -2537,14 +2537,14 @@ func cvtDirect(v Value, typ Type) Value { // convertOp: concrete -> interface func cvtT2I(v Value, typ Type) Value { - target := new(interface{}) + target := unsafe_New(typ.common()) x := valueInterface(v, false) if typ.NumMethod() == 0 { - *target = x + *(*interface{})(target) = x } else { - ifaceE2I(typ.(*rtype), x, unsafe.Pointer(target)) + ifaceE2I(typ.(*rtype), x, target) } - return Value{typ.common(), unsafe.Pointer(target) /* 0, */, v.flag&flagRO | flagIndir | flag(Interface)<<flagKindShift} + return Value{typ.common(), target /* 0, */, v.flag&flagRO | flagIndir | flag(Interface)<<flagKindShift} } // convertOp: interface -> interface |