Is this function pure?
Janice Caron
caron800 at googlemail.com
Tue Sep 18 11:42:18 PDT 2007
On 9/18/07, Ingo Oeser <ioe-news at rameria.de> wrote:
> A valid optimisation is to assume that x -> a.length, since a.length
> is directly derived from x. If you don't use (e.g. reference) the memory
> you are allocating, the compiler should be free to optimise the allocation
> away.
OK, so change it to
char[] probablyNotPure(int x)
{
try
{
char[] a = new char[x];
return a;
}
catch
{
return null;
}
}
and consider that the input might be 0x7FFFFFFF.
I think it looks less easy to optimise now.
More information about the Digitalmars-d
mailing list