[webkit-dev] Using C++ constant local variables in WebKit

Ryosuke Niwa rniwa at webkit.org
Wed Nov 30 18:43:00 PST 2011

On Wed, Nov 30, 2011 at 6:26 PM, Ojan Vafai <ojan at chromium.org> wrote:

> On Wed, Nov 30, 2011 at 5:12 PM, Alexey Proskuryakov <ap at webkit.org>wrote:
>> 30.11.2011, в 17:00, David Kilzer написал(а):
>> -                char* bufferStart = bufferPos;
>> +                char* const bufferStart = bufferPos;
>> FWIW, working with code that parses strings is when I also always find
>> myself eager to use const local variables (pointers or indices).
> I don't mind using const in some cases, but I share Darin's concern of
> littering the code with consts. I'd prefer that we come up with a fairly
> conservative guideline about when to use it. I'm not sure what that would
> look like. We could start with, what's special about this case, or string
> parsing in general that makes using const more valuable?

I'd rather not have a precise rule and leave it to reviewers' discretion
because the usefulness of const local variable depends a lot on the
context. e.g. using local const is very helpful in a 1000-line function
whereas it's less useful in a 5-line function.

- Ryosuke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20111130/fcb6cf62/attachment.html>

More information about the webkit-dev mailing list