[webkit-changes] [WebKit/WebKit] 9359aa: Optimize WTF::spanReinterpretCast

Commit Queue noreply at github.com
Thu Sep 26 14:47:22 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9359aad17416457adec2639e7ef4acec30cbddfa
      https://github.com/WebKit/WebKit/commit/9359aad17416457adec2639e7ef4acec30cbddfa
  Author: David Kilzer <ddkilzer at apple.com>
  Date:   2024-09-26 (Thu, 26 Sep 2024)

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

  Log Message:
  -----------
  Optimize WTF::spanReinterpretCast
<https://bugs.webkit.org/show_bug.cgi?id=280032>
<rdar://136330115>

Reviewed by Alex Christensen.

* Source/WTF/wtf/StdLibExtras.h:
(WTF::spanReinterpretCast):
- Fix Extent in return type when std::dynamic_extent is not used.
- Prevent change of size in bytes when passing through
  spanReinterpretCast():
  - Limit RELEASE_ASSERT() to cases where std::dynamic_extent is used,
    and one of the following criteria:
    - The source type is smaller than the destination type, or
    - The source type is not an integral multiple of the destination
      type.
  - Use static_assert() when not using std::dynamic_extent.
- Fix name of function in message for static_assert() const-ness check.

* Tools/TestWebKitAPI/Tests/WTF/StdLibExtrasTests.cpp:
(TestWebKitAPI::TEST(WTF_StdLibExtras, SpanReinterpretCast_DynamicExtent)): Add.
(TestWebKitAPI::TEST(WTF_StdLibExtras, SpanReinterpretCast_DynamicExtent_ManualRuntimeErrors)): Add.
(TestWebKitAPI::TEST(WTF_StdLibExtras, SpanReinterpretCast_NonDynamicExtent)): Add.
(TestWebKitAPI::TEST(WTF_StdLibExtras, SpanReinterpretCast_NonDynamicExtent_CompileTimeErros)): Add.
- Add tests.

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



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


More information about the webkit-changes mailing list