[Mono-dev] [SPAM] Re: ToString() performace in Mono revisited
prakash at punnoor.de
Wed Jan 2 13:30:05 EST 2008
On the day of Wednesday 02 January 2008 Miguel de Icaza hast written:
> > The array initialization should also be done lazily and not in the static
> > constructor (should be removed completely because it drags in other
> > static fields that need to be preinitialized, code compiled and so on).
> > Especially the Hex support is IMHO completely off bounds. I (personally)
> > rarely see hex output and making EVERYBODY pay for a hex speedup doesn't
> > seem right. A simple
> > if (array == null) Init ();
> > will be enough. You will pay per-call, but it is relatively cheap.
> The only thing that is worth keeping in mind is that if this is a static
> field, initialization probably needs to be protected by a lock (I say
> probably, because we *could* ignore the race by carefully making sure
> that we assign the public array only after it has been initialized, so
> we would end up with N copies of an array initialized in the worst case,
> but N-1 will be discarded by the GC).
You can also use the Bill Pugh's trick by using a nested class, so the jit
should lazily initialize it (it works with .net, no idea whether it does with
//\ Prakash Punnoor /\\
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080102/265b2446/attachment.bin
More information about the Mono-devel-list