[llvm-commits] [llvm] r76910 - in /llvm/trunk: include/llvm/Support/FormattedStream.h lib/Support/FormattedStream.cpp

David A. Greene greened at obbligato.org
Tue Jul 28 09:52:59 PDT 2009


On Thursday 23 July 2009 18:44, Chris Lattner wrote:
> On Jul 23, 2009, at 4:21 PM, David Greene wrote:
> > URL: http://llvm.org/viewvc/llvm-project?rev=76910&view=rev
> > Log:
> > Write space padding as one string to speed up comment printing.
>
> Hi David,
>
> > +  // Keep a buffer of spaces handy to speed up processing.
> > +  static char Spaces[MAX_COLUMN_PAD];
> > +  static bool Initialized = false;
> > +  if (!Initialized) {
>
> This won't work because it isn't thread safe.  Why not just use:

Why isn't it thread safe?  Multiple threads might enter the then-clause
but they're all doing the same thing and it's an idempotent operation.

> const char *Spaces = "             .... ";
> write(Spaces, num);

That's better.

                               -Dave



More information about the llvm-commits mailing list