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@lists.webkit.org> wrote:
> 
> 
>> On Oct 3, 2024, at 14:24, Chris Dumez via webkit-dev 
>> <webkit-dev@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@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to