[Mono-devel-list] The first (attempt to checkin) managed collation patch

Paolo Molaro lupus at ximian.com
Fri Jul 22 05:17:44 EDT 2005

On 07/21/05 Ben Maurer wrote:
> On Fri, 2005-07-22 at 12:53 +0900, Atsushi Eno wrote:
> > +	class UnmanagedMemoryStream : Stream {
> >  		unsafe byte *base_address;
> > -		int size;
> > -		int position;
> > +		long size;
> > +		long position;
> It's a bit more efficient so store those as void*. It uses less memory
> on x86 boxes. Also, the 32 bit opcodes are shorter (ie, in size += 1,
> you can do that with a single inc rather than having to handle
> overflow).

It doesn't make sense to store any of those fields as void*.
position can become a byte*, but its' meaning needs to change from
'offset from base' to 'current byte addr'. The Position property
can be easily implemented with a subtraction.
size can go away and it can be replaced by a byte* end_buf
set in the costructor to base + size.
These changes will simplify some of the checks, too.

That said, please remember that for the application we are discussing
in the thread (the collation tables), resources and streams must not be
used. They could be used for byte arrays, but it's a waste to create
the stream object and compile all the needed reflection code when a simple
icall can return the pointer to the data.
In the case of ushort or int arrays, the data would need to be
copied and byteswapped, which is bad.


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

More information about the Mono-devel-list mailing list