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

  Changed paths:
    M Source/WTF/wtf/EmbeddedFixedVector.h
    M Source/WTF/wtf/FixedVector.h
    M Source/WTF/wtf/TrailingArray.h
    M Tools/TestWebKitAPI/Tests/WTF/FixedVector.cpp

  Log Message:
  -----------
  `FixedVector(size, value)` should not double-initialize non-POD elements
https://bugs.webkit.org/show_bug.cgi?id=310963

Reviewed by Sam Weinig.

The `FixedVector(size_t, const T&)` constructor was first
default-constructing all elements via `Storage::create(size)`, then
copy-assigning over them with `fill(value)`. For non-POD types, this
means N default constructions + N copy assignments instead of just
N copy constructions.

Fix this by adding a `createFilled()` factory to `EmbeddedFixedVector`
backed by a new `TrailingArray` FillWith constructor that uses
`VectorTypeOperations::uninitializedFill`, matching what
`Vector(size, val)` already does.

Also add API test coverage for this constructor, which had none.

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

* Source/WTF/wtf/EmbeddedFixedVector.h:
* Source/WTF/wtf/FixedVector.h:
(WTF::FixedVector::FixedVector):
* Source/WTF/wtf/TrailingArray.h:
(WTF::TrailingArray::TrailingArray):
* Tools/TestWebKitAPI/Tests/WTF/FixedVector.cpp:
(TestWebKitAPI::TEST(WTF_FixedVector, SizeAndValueConstructorPOD)):
(TestWebKitAPI::TEST(WTF_FixedVector, SizeAndValueConstructorNonPOD)):
(TestWebKitAPI::TEST(WTF_FixedVector, SizeAndValueConstructorZeroSize)):
(TestWebKitAPI::TEST(WTF_FixedVector, SizeAndValueConstructorSingleElement)):

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



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

Reply via email to