[webkit-dev] Removal of makeRef() / makeRefPtr()

Chris Dumez cdumez at apple.com
Wed Sep 22 09:28:00 PDT 2021


Hi,

With WebKit adopting C++17 a while back, there are no longer any benefits to using makeRef() / makeRefPtr() as far as I can tell.

Code that was written like so:
auto protectedThis = makeRef(*this);
auto protectedPage = makeRefPtr(page);
auto result = makeRef(foo->bar());
auto lambda = [protectedThis = makeRef(*this)] { };
m_node = makeRef(node); // m_node being a Ref<Node>
m_node = makeRefPtr(node); // m_node being a RefPtr<Node>

Can now be written in a more concise way:
Ref protectedThis { *this };
RefPtr protectedPage { page };
Ref result = foo->bar();
auto lambda = [protectedThis = Ref { *this }] { };
m_node = node;
`m_node = node;` or `m_node = &node; // depending if node is a reference or pointer.

I am currently in the process on transitioning our code from one style to the other and removing makeRef() / makeRefPtr() altogether.
I am sending this email so people are not confused when they try to use makeRef() / makeRefPtr() in new code.

--
 Chris Dumez




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20210922/8951711b/attachment.htm>


More information about the webkit-dev mailing list