[Mono-devel-list] Zero Length Arrays
Jeroen Frijters
jeroen at sumatra.nl
Mon Jan 12 05:13:59 EST 2004
Ben Maurer wrote:
> So, today, I realized that there is a VERY simple solution. In
> mono_array_new, if it finds that it will be creating a zero length
> array, it should used a cached zero length array.
ECMA says:
"The newarr instruction pushes a reference to a *new* zero-based,
one-dimensional array" (my emphasis).
This optimization is not allowed. Plain and simple.
Piers Haken wrote:
> What about locking?
This is why the optimization isn't legal. The following pattern is
should work:
object myLock = new object[0];
lock(myLock)
{
}
Regards,
Jeroen
More information about the Mono-devel-list
mailing list