Hi, I have recently landed stricter type checking in downcast<>() [1]. It is stricter because the check is now happening in release / production builds on some platforms (ARM-based). My objective is to enable to check in release on all platforms in the near future (still a small performance hit on remaining platforms at the moment).
Because of this, it is now recommended to use dynamicDowncast<>() instead of is<>() + downcast<>(), to avoid duplicating the type check. dynamicDowncast<>() is also less error-prone and often results in more concise code. If you have a case where performance matters and you’re confident a type check is not required, you may rely on uncheckedDowncast<>(). uncheckedDowncast<>() behaves the same way downcast<>() used to before my change (type check on debug builds only). One such example I’ve seen in our codebase is when using a switch statement based on the type: ``` switch (node.nodeType()) { case Node::DOCUMENT_TYPE_NODE: uncheckedDowncast<DocumentType>(node)->foo(); ``` Please let me know if you have any concerns / questions. Cheers, Chris Dumez. [1] https://commits.webkit.org/272296@main
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev