LibWeb: Ensure static cast is used when possible in as_if

This commit is contained in:
Tim Ledbetter 2025-08-22 15:33:35 +01:00 committed by Jelle Raaijmakers
commit 4e57a2aedf
Notes: github-actions[bot] 2025-08-22 18:27:25 +00:00

View file

@ -40,11 +40,10 @@ ALWAYS_INLINE CopyConst<InputType, OutputType>* as_if(InputType& input)
{
if (!is<OutputType>(input))
return nullptr;
if constexpr (IsBaseOf<InputType, OutputType>) {
if constexpr (requires { static_cast<CopyConst<InputType, OutputType>*>(&input); }) {
return static_cast<CopyConst<InputType, OutputType>*>(&input);
} else {
return dynamic_cast<CopyConst<InputType, OutputType>*>(&input);
}
return dynamic_cast<CopyConst<InputType, OutputType>*>(&input);
}
template<typename OutputType, typename InputType>