mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibJS+LibWeb: Use GC::Weak instead of AK::WeakPtr for GC-allocated types
This makes some common types like JS::Object smaller (by 8 bytes) and yields a minor speed improvement on many benchmarks.
This commit is contained in:
parent
25a5ed94d6
commit
dfa796a4e4
Notes:
github-actions[bot]
2025-10-17 15:25:08 +00:00
Author: https://github.com/awesomekling
Commit: dfa796a4e4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6496
36 changed files with 111 additions and 115 deletions
|
|
@ -218,25 +218,25 @@ ErrorOr<void> WebSocket::establish_web_socket_connection(URL::URL const& url_rec
|
|||
|
||||
m_websocket = request_client->websocket_connect(url_record, origin_string, protocol_byte_strings, {}, additional_headers);
|
||||
|
||||
m_websocket->on_open = [weak_this = make_weak_ptr<WebSocket>()] {
|
||||
m_websocket->on_open = [weak_this = GC::Weak { *this }] {
|
||||
if (!weak_this)
|
||||
return;
|
||||
auto& websocket = const_cast<WebSocket&>(*weak_this);
|
||||
websocket.on_open();
|
||||
};
|
||||
m_websocket->on_message = [weak_this = make_weak_ptr<WebSocket>()](auto message) {
|
||||
m_websocket->on_message = [weak_this = GC::Weak { *this }](auto message) {
|
||||
if (!weak_this)
|
||||
return;
|
||||
auto& websocket = const_cast<WebSocket&>(*weak_this);
|
||||
websocket.on_message(move(message.data), message.is_text);
|
||||
};
|
||||
m_websocket->on_close = [weak_this = make_weak_ptr<WebSocket>()](auto code, auto reason, bool was_clean) {
|
||||
m_websocket->on_close = [weak_this = GC::Weak { *this }](auto code, auto reason, bool was_clean) {
|
||||
if (!weak_this)
|
||||
return;
|
||||
auto& websocket = const_cast<WebSocket&>(*weak_this);
|
||||
websocket.on_close(code, String::from_byte_string(reason).release_value_but_fixme_should_propagate_errors(), was_clean);
|
||||
};
|
||||
m_websocket->on_error = [weak_this = make_weak_ptr<WebSocket>()](auto) {
|
||||
m_websocket->on_error = [weak_this = GC::Weak { *this }](auto) {
|
||||
if (!weak_this)
|
||||
return;
|
||||
auto& websocket = const_cast<WebSocket&>(*weak_this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue