mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +00:00
Kernel: Always inline some KResult / KResultOr<> methods
Namely, those that contain assertions that can be easily eliminated at call site.
This commit is contained in:
parent
1b4e88fb59
commit
1e266aec27
Notes:
sideshowbarker
2024-07-19 05:52:54 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/1e266aec279 Pull-request: https://github.com/SerenityOS/serenity/pull/2482
|
@ -37,7 +37,7 @@ enum KSuccessTag {
|
|||
|
||||
class KResult {
|
||||
public:
|
||||
explicit KResult(int negative_e)
|
||||
ALWAYS_INLINE explicit KResult(int negative_e)
|
||||
: m_error(negative_e)
|
||||
{
|
||||
ASSERT(negative_e <= 0);
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
private:
|
||||
template<typename T>
|
||||
friend class KResultOr;
|
||||
KResult() {}
|
||||
KResult() { }
|
||||
|
||||
int m_error { 0 };
|
||||
};
|
||||
|
@ -116,24 +116,24 @@ public:
|
|||
}
|
||||
|
||||
bool is_error() const { return m_is_error; }
|
||||
KResult error() const
|
||||
ALWAYS_INLINE KResult error() const
|
||||
{
|
||||
ASSERT(m_is_error);
|
||||
return m_error;
|
||||
}
|
||||
KResult result() const { return m_is_error ? KSuccess : m_error; }
|
||||
T& value()
|
||||
ALWAYS_INLINE T& value()
|
||||
{
|
||||
ASSERT(!m_is_error);
|
||||
return *reinterpret_cast<T*>(&m_storage);
|
||||
}
|
||||
const T& value() const
|
||||
ALWAYS_INLINE const T& value() const
|
||||
{
|
||||
ASSERT(!m_is_error);
|
||||
return *reinterpret_cast<T*>(&m_storage);
|
||||
}
|
||||
|
||||
T release_value()
|
||||
ALWAYS_INLINE T release_value()
|
||||
{
|
||||
ASSERT(!m_is_error);
|
||||
T released_value = *reinterpret_cast<T*>(&m_storage);
|
||||
|
|
Loading…
Reference in a new issue