dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pnet-developers] quick boxing question


From: Gopal V
Subject: Re: [Pnet-developers] quick boxing question
Date: Wed, 23 Jul 2003 00:54:28 +0530
User-agent: Mutt/1.2.5i

If memory serves me right, Neil Cawse wrote:
> I need to efficiently copy an array of structs.
> 
> Can I do something like:
> 
> reg1.rects = (RectangleF[])reg2.rects.Clone();
> 
> or will this cause boxing and then unboxing?

IIRC ... no ... Array.Clone() does not box ... and
CastClass does not allow boxing conversions for 
arrays ..  

cvm_ptr.c (CanCastClass):81
                if(ILType_IsArray(fromType) && ILType_IsArray(toType) &&
                   ILTypeGetRank(fromType) == ILTypeGetRank(toType))
                {
                        return ILTypeAssignCompatibleNonBoxing
                          (image, ILTypeGetElemType(fromType), 
ILTypeGetElemType(toType));
                }
                else
                {
                        return 0;
                }

So you see :)

In fact the COP_CASTCLASS operand thus does not really do anything , 
except validate the casting :) ... no changes whatsoever. So generally
speaking this is faster than new Array , Array.Copy() ... (which is
probably what you wanted to confirm...)

Gopal
-- 
The difference between insanity and genius is measured by success


reply via email to

[Prev in Thread] Current Thread [Next in Thread]