[webkit-reviews] review granted: [Bug 188146] Use constexpr constructors more instead of NeverDestroyed : [Attachment 346028] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jul 29 10:43:09 PDT 2018


Darin Adler <darin at apple.com> has granted Yusuke Suzuki
<utatane.tea at gmail.com>'s request for review:
Bug 188146: Use constexpr constructors more instead of NeverDestroyed
https://bugs.webkit.org/show_bug.cgi?id=188146

Attachment 346028: Patch

https://bugs.webkit.org/attachment.cgi?id=346028&action=review




--- Comment #2 from Darin Adler <darin at apple.com> ---
Comment on attachment 346028
  --> https://bugs.webkit.org/attachment.cgi?id=346028
Patch

Change seems fine.

Bug title is a bit inaccurate.

Having a constexpr constructor does not affect whether NeverDestroyed is
needed. It does affect whether we can have a global outside a function. If the
constructor is not constexpr it needs to be inside a function so it gets run
the first time the function is installed rather than at load time.

What affects the need for NeverDestroyed is whether the class has a trivial
destructor. If it does then NeverDestroyed is not needed.

In all these cases in this patch we changed both things but they are
independent.

You can have a static without NeverDestroyed if the destructor is trivial. You
can have a global outside a function that uses NeverDestroyed as long as the
entire constructor is all constexpr. (Might need to fix NeverDestroyed
implementation to be sure it’s constructors are constexpr.)


More information about the webkit-reviews mailing list