[Mono-dev] [PATCH] Managed Marshal.Copy implemantations

Paolo Molaro lupus at ximian.com
Sat Mar 15 08:45:57 EDT 2008


On 02/22/08 Kornél Pál wrote:
> If there were something like a fast Array.GetElementSize() that could be 
> used in Marshal.UnsafeAddrOfPinnedArrayElement as well as in System.Buffer 
> methods. System.Buffer is supposed to be used over Array.Copy for better 
> performance so I believe that having a managed System.Buffer would affect 
> overall performance.
>
> You have written that GetElementSize() should not be added yet. Is there an 
> ongoing work that would interfere with this or why should that wait?

There are two issues.
First that is related to a different change that the rest of the patch:
it's better to do things incrementally instead of conflating multiple
things into the same changeset.
Second, GetElementSize () is not the right interface for use inside
Buffer. Buffer only applies for a subset of the arrays (basic types and
maybe valuetypes of basic types only, I didn't check all the allowed
cases). So you'd need at least another icall that says if the Copy
operations are allowed on the array. It's better to have a single icall
that does it all, returning 0 for the cases where the copy is not
allowed. In that case the name GetElementSize would be wrong.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better


More information about the Mono-devel-list mailing list