mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
Userland: Replace VERIFY(is<T>) with verify_cast<T>
Instead of doing a VERIFY(is<T>(x)) and *then* casting it to T, we can just do the cast right away with verify_cast<T>. :^)
This commit is contained in:
parent
7fef8c5648
commit
e59bf87374
10 changed files with 26 additions and 43 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
|
@ -720,31 +721,27 @@ ALWAYS_INLINE bool is<OpCode_Compare>(const OpCode& opcode)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE const T& to(const OpCode& opcode)
|
||||
ALWAYS_INLINE T const& to(OpCode const& opcode)
|
||||
{
|
||||
VERIFY(is<T>(opcode));
|
||||
return static_cast<const T&>(opcode);
|
||||
return verify_cast<T>(opcode);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE T* to(OpCode* opcode)
|
||||
{
|
||||
VERIFY(is<T>(opcode));
|
||||
return static_cast<T*>(opcode);
|
||||
return verify_cast<T>(opcode);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE const T* to(const OpCode* opcode)
|
||||
ALWAYS_INLINE T const* to(OpCode const* opcode)
|
||||
{
|
||||
VERIFY(is<T>(opcode));
|
||||
return static_cast<const T*>(opcode);
|
||||
return verify_cast<T>(opcode);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE T& to(OpCode& opcode)
|
||||
{
|
||||
VERIFY(is<T>(opcode));
|
||||
return static_cast<T&>(opcode);
|
||||
return verify_cast<T>(opcode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue