diff options
author | Sergey Bugaev <bugaevc@serenityos.org> | 2020-06-02 19:30:14 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-02 21:49:47 +0200 |
commit | 1e266aec279cea9d29f8d8c03c5cfeb01353f7c3 (patch) | |
tree | 5536fd6666ac45f9bdc396d09795f1f5efe54a25 /Kernel/KResult.h | |
parent | 1b4e88fb59d35d7d720de15ddbdd6975d7175964 (diff) | |
download | serenity-1e266aec279cea9d29f8d8c03c5cfeb01353f7c3.zip |
Kernel: Always inline some KResult / KResultOr<> methods
Namely, those that contain assertions that can be easily eliminated at call site.
Diffstat (limited to 'Kernel/KResult.h')
-rw-r--r-- | Kernel/KResult.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Kernel/KResult.h b/Kernel/KResult.h index 43831fe258..35f9a28ea2 100644 --- a/Kernel/KResult.h +++ b/Kernel/KResult.h @@ -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); |