[llvm-commits] [PATCH 07/20] [AVX] Unique BitInit

David Blaikie dblaikie at gmail.com
Tue Jul 19 13:22:34 PDT 2011


> -  return new BitInit(V);
> +  static const BitInit *True  = 0;
> +  static const BitInit *False = 0;
> +
> +  const BitInit **Result = (V ? &True : &False);
> +
> +  if (*Result == 0)
> +    *Result = new BitInit(V);
> +
> +  return *Result;

You could use a reference here:

const BitInit &*Result = (V ? True : False);
if (Result == 0)
  Result = new BitINit(...);

I'm not sure what LLVM's coding conventions are on the use of
immediate static values rather than lazy initialization, but in this
case is there a particular reason these are lazy? (if so, a comment
explaining the necessity, if it's out of character/special, might be
in order)

- David




More information about the llvm-commits mailing list