[webkit-changes] [WebKit/WebKit] 0c0b20: [WK2] Decoding in ArgumentCoder<Vector<T>> should ...

Žan Doberšek noreply at github.com
Mon Dec 12 05:54:35 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0c0b2027ab6bc02c2c08fbde469af8d2e28da9d6
      https://github.com/WebKit/WebKit/commit/0c0b2027ab6bc02c2c08fbde469af8d2e28da9d6
  Author: Žan Doberšek <zdobersek at igalia.com>
  Date:   2022-12-12 (Mon, 12 Dec 2022)

  Changed paths:
    M Source/WebKit/Platform/IPC/ArgumentCoders.h
    M Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp

  Log Message:
  -----------
  [WK2] Decoding in ArgumentCoder<Vector<T>> should reserve initial capacity, avoid shrink-to-fit
https://bugs.webkit.org/show_bug.cgi?id=249077

Reviewed by Kimmo Kinnunen.

When decoding a Vector of non-trivial elements, use the decoded size to
reserve initial capacity and then perform unchecked appends of each
decoded element. This replaces the incremental grow-as-you-go appending
and the final shrink-to-fit operation which possibly ends up moving over
all the elements into the newly-allocated smaller buffer.

The decoding-moves-counter test is updated, with the only remaining and
unavoidable move of each element contained in the Vector happening when
that element is moved into the resulting Vector.

* Source/WebKit/Platform/IPC/ArgumentCoders.h:
* Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp:
(TestWebKitAPI::TEST_F):

Canonical link: https://commits.webkit.org/257725@main




More information about the webkit-changes mailing list