[Mono-devel-list] Zero Length Arrays

Ben Maurer bmaurer at users.sourceforge.net
Mon Jan 12 00:07:12 EST 2004

On Mon, 2004-01-12 at 07:16, Jonathan Gilbert wrote:
> At 08:42 PM 11/01/2004 -0500, you wrote:
> >On Sun, 2004-01-11 at 20:34, Piers Haken wrote:
> >> What about locking? 
> >Multiple threads could try to allocate a zero length array at the same
> >time.
> What about this pattern?
> object[] x = new object[0];
> object[] y = new object[0];
> if (object.ReferenceEquals(x, y)) throw new
> TheRuntimeIsInsaneException("Houston, we have a problem");
I think you can argue that it is runtime defined. For example, I would
consider it valid for:

(object)0 == (object)0

To be true (two value types get boxed to the same thing).

> Anyway, are arrays of length 0 really being created so often that a cheap
> speed hack is needed?
You can see it in some areas.

More information about the Mono-devel-list mailing list