[webkit-dev] Using C++ constant pointers (type_name * const) in WebKit

David Kilzer ddkilzer at webkit.org
Mon Nov 28 13:38:32 PST 2011


In a discussion on Bug 71921, Antti, Darin Adler and I started a discussion about using C++ constant pointers in WebKit.  Does the WebKit community have a consensus opinion on the matter?

* Pros
  - Documents use of variable.
  - Prevents misuse of variable in a later patch (by a different author) through enforcement of pointer const-ness.
  - May help compiler optimize code.  (We weren't sure whether modern compilers do this on their own or not.)

* Cons
  - Darin Adler doesn't ever recall fixing a bug in WebKit where a constant pointer would have helped.
  - Slightly more verbose syntax for constant pointers to a constant string (const char * const pointer;) or even a constant pointer to a mutable string (char * const pointer;).

Dave

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20111128/0dd8ace4/attachment.html>


More information about the webkit-dev mailing list