Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9c6d843b1dc094b677f052ddd9e6c4e9f39c87cc
https://github.com/WebKit/WebKit/commit/9c6d843b1dc094b677f052ddd9e6c4e9f39c87cc
Author: Yijia Huang <[email protected]>
Date: 2025-02-13 (Thu, 13 Feb 2025)
Changed paths:
M Source/WTF/wtf/EnumTraits.h
M Tools/TestWebKitAPI/Tests/WTF/EnumTraits.cpp
Log Message:
-----------
[WTF] Refactor EnumTraits to improve constexpr evaluation and handling of
signed enums
https://bugs.webkit.org/show_bug.cgi?id=287370
rdar://144487521
Reviewed by Keith Miller.
This patch:
1. Removed unnecessary forConstexpr, replacing it with std::index_sequence for
better compile-time performance.
2. Improved handling of signed enums by introducing enumNamesMin and
enumNamesMax,
ensuring min and max values are within the valid range of the underlying
type.
3. Optimized the computation of enumNamesSize to prevent overflow and ensure
correctness for signed and unsigned enums.
4. Updated enumName lookup logic to correctly compute indices for signed enums
using unsigned arithmetic.
5. Added new test cases to cover signed and unsigned enums, including cases with
negative values, large gaps, and out-of-range lookups.
This change ensures robust handling of enums with various underlying types,
prevents
unexpected overflows, and enhances overall constexpr evaluation efficiency.
* Source/WTF/wtf/EnumTraits.h:
(WTF::enumName):
(WTF::enumNames): Deleted.
* Tools/TestWebKitAPI/Tests/WTF/EnumTraits.cpp:
(TestWebKitAPI::TEST(WTF_EnumTraits, EnumNameArgument)):
Canonical link: https://commits.webkit.org/290345@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes