mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-29 21:57:18 +00:00
AK: Fix usage of constexpr within Utf16View and related utilities
* Error and ErrorOr are not themelves constexpr, so a function returning these types cannot be constexpr. * The UDL was trying to call Utf16View::validate, which is not constexpr itself. The compiler will actually already raise an error if a UTF-16 literal is invalid, so let's just avoid the call altogether.
This commit is contained in:
parent
778759517e
commit
418409aa6f
Notes:
github-actions[bot]
2025-07-04 13:26:29 +00:00
Author: https://github.com/trflynn89
Commit: 418409aa6f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5299
Reviewed-by: https://github.com/shannonbooth ✅
2 changed files with 3 additions and 5 deletions
|
@ -137,7 +137,7 @@ template<typename Callback>
|
|||
}
|
||||
|
||||
template<FallibleFunction<char16_t> Callback>
|
||||
constexpr ErrorOr<size_t> try_code_point_to_utf16(u32 code_point, Callback callback)
|
||||
ALWAYS_INLINE ErrorOr<size_t> try_code_point_to_utf16(u32 code_point, Callback callback)
|
||||
{
|
||||
if (code_point < FIRST_SUPPLEMENTARY_PLANE_CODE_POINT) {
|
||||
TRY(callback(static_cast<char16_t>(code_point)));
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
Utf16CodePointIterator(char16_t const* ptr, size_t length)
|
||||
constexpr Utf16CodePointIterator(char16_t const* ptr, size_t length)
|
||||
: m_iterator(ptr)
|
||||
, m_remaining_code_units(length)
|
||||
{
|
||||
|
@ -346,9 +346,7 @@ struct Traits<Utf16View> : public DefaultTraits<Utf16View> {
|
|||
|
||||
[[nodiscard]] ALWAYS_INLINE AK_STRING_VIEW_LITERAL_CONSTEVAL AK::Utf16View operator""sv(char16_t const* string, size_t length)
|
||||
{
|
||||
AK::Utf16View view { string, length };
|
||||
ASSERT(view.validate());
|
||||
return view;
|
||||
return { string, length };
|
||||
}
|
||||
|
||||
#if USING_AK_GLOBALLY
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue