r186383 - Add 'const' qualifiers to static const char* variables.

Craig Topper craig.topper at gmail.com
Tue Jul 16 11:23:27 PDT 2013


As they are declared static, I think the compiler will optimize out the
pointer storage and lookup completely so there should be no wasted space or
pointer indirection.


On Tue, Jul 16, 2013 at 6:42 AM, Jonathan Sauer <jonathan.sauer at gmx.de>wrote:

> Hello,
>
> > -static const char *StrEnteringLoop = "Entering loop body";
> > -static const char *StrLoopBodyZero = "Loop body executed 0 times";
> > +static const char *const StrEnteringLoop = "Entering loop body";
> > +static const char *const StrLoopBodyZero = "Loop body executed 0 times";
>
> Why not replace the pointers with arrays:
>
> > static const char StrEnteringLoop[] = "Entering loop body";
>
> That would avoid having to remember to add two const. It could even result
> in slightly (very very slightly) faster code as it would remove a pointer
> indirection.
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



-- 
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130716/3480dc1c/attachment.html>


More information about the cfe-commits mailing list