[webkit-changes] [WebKit/WebKit] 1a7b36: [WK2] Reduce moves/copies when decoding through th...
Žan Doberšek
noreply at github.com
Fri Dec 9 04:36:03 PST 2022
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 1a7b36e70573fcf071a53c98058be7284154f61c
https://github.com/WebKit/WebKit/commit/1a7b36e70573fcf071a53c98058be7284154f61c
Author: Žan Doberšek <zdobersek at igalia.com>
Date: 2022-12-09 (Fri, 09 Dec 2022)
Changed paths:
M Source/WebKit/Platform/IPC/ArgumentCoders.cpp
M Source/WebKit/Platform/IPC/ArgumentCoders.h
M Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp
Log Message:
-----------
[WK2] Reduce moves/copies when decoding through the general ArgumentCoder specializations
https://bugs.webkit.org/show_bug.cgi?id=248963
Reviewed by Kimmo Kinnunen.
Improve decoding efficiency in the general ArgumentCoder specializations
by avoiding the stream extraction operator when decoding from a given
decoder object, and by utilizing in-place construction of objects
wrapped in std::optional<>.
Using the decoder's decode<T>() method to retrieve an object from the
decoder is beneficial to first default-constructing a std::optional<>
object and then targeting it with the stream extraction operator
invocation since it avoids one move or copy operation. This is adopted
through all the ArgumentCoder specializations in WebKit's ArgumentCoders
header and implementation file.
Where already possible, in-place construction of objects wrapped in
std::optional<> is done through the use of std::make_optional(). This
also avoids additional move or copy operations.
The reduction in those operations is reflected in the
decoding-of-move-counter unit tests, specifically in the lowering of
move operations for different types. A unit test covering std::variant<>
is also added.
Another unit test covering Expected<ValueType, ErrorType> types will be
added separately, along with move-semantics support for those types on
the encoding side.
* Source/WebKit/Platform/IPC/ArgumentCoders.cpp:
(IPC::ArgumentCoder<CString>::decode):
(IPC::ArgumentCoder<String>::decode):
* Source/WebKit/Platform/IPC/ArgumentCoders.h:
(IPC::ArgumentCoder<OptionSet<T>>::decode):
(IPC::ArgumentCoder<std::optional<T>>::decode):
(IPC::ArgumentCoder<Box<T>>::decode):
* Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp:
(TestWebKitAPI::TEST_F):
Canonical link: https://commits.webkit.org/257621@main
More information about the webkit-changes
mailing list