[webkit-dev] Naming scheme for fooIfExists/ensureFoo - Round 2

Said Abou-Hallawa sabouhallawa at apple.com
Thu Oct 3 14:37:14 PDT 2024


Sometimes I can’t use ensureXXX() because there is no guarantee the object will be created always. And I have to even use this pattern:

Object* objectIfExists() { return m_object.get(); }
Object* object(); // It try to create m_object but it still may return nullptr;

> On Oct 3, 2024, at 2:33 PM, Abrar Protyasha via webkit-dev <webkit-dev at lists.webkit.org> wrote:
> 
> 
>> On Oct 3, 2024, at 14:24, Chris Dumez via webkit-dev <webkit-dev at lists.webkit.org> wrote:
>> 
>> Do we have stats about which pattern is more common in our codebase?
> 
> 
> % rg "\* .+IfExists\(" -th | wc -l
> 95
> 
> % rg "\& ensure.+\(" -th | wc -l
> 176
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20241003/40cde64d/attachment.htm>


More information about the webkit-dev mailing list