Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9b1252efbbc4fba4423a37b453d91584fc59153e
      
https://github.com/WebKit/WebKit/commit/9b1252efbbc4fba4423a37b453d91584fc59153e
  Author: Chris Dumez <[email protected]>
  Date:   2026-03-28 (Sat, 28 Mar 2026)

  Changed paths:
    M Source/WTF/wtf/Vector.h
    M Tools/TestWebKitAPI/Tests/WTF/Vector.cpp

  Log Message:
  -----------
  Optimize Vector::appendVector(&&) to use bulk move instead of per-element 
append
https://bugs.webkit.org/show_bug.cgi?id=310887

Reviewed by Darin Adler.

The rvalue overload of `appendVector()` was appending elements one at a time
via `unsafeAppendWithoutCapacityCheck()`, which issues a separate ASan
annotation and m_size increment per element. For types with
canMoveWithMemcpy (e.g. int, pointers), this also prevents the compiler
from coalescing N individual copies into a single memcpy.

Replace with a bulk approach: a single ASan annotation, a single memcpy
for trivially-movable types (or a tight placement-new loop for non-trivial
types), and a single m_size update.

Also add comprehensive API tests for both appendVector overloads covering
trivial types (memcpy path), MoveOnly types (element-by-element path),
empty vectors, capacity expansion, inline buffers, and large vectors.

Test: Tools/TestWebKitAPI/Tests/WTF/Vector.cpp

* Source/WTF/wtf/Vector.h:
(WTF::VectorTypeOperations::uninitializedMove):
(WTF::Malloc>::appendVector):
* Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorCopyTrivial)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorCopyEmpty)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorCopyToEmpty)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveTrivial)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveEmpty)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveToEmpty)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveTriggersExpansion)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveMoveOnly)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveMoveOnlyEmpty)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveMoveOnlyToEmpty)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveMoveOnlyTriggersExpansion)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveInlineCapacity)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveInlineToHeap)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveLarge)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveRefPtr)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveRef)):
(TestWebKitAPI::TEST(WTF_Vector, AppendVectorMoveRefPtrTriggersExpansion)):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to