1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:57:35 +00:00

Kernel: KResultOr can use the same storage as the object for the error

Since it can only hold either an object or an error code, we can share
the same storage to hold either.
This commit is contained in:
Tom 2021-02-07 15:30:23 -07:00 committed by Andreas Kling
parent 79bab28f5e
commit 1d843c46eb

View file

@ -172,8 +172,10 @@ public:
} }
private: private:
union {
alignas(T) char m_storage[sizeof(T)]; alignas(T) char m_storage[sizeof(T)];
KResult m_error; KResult m_error;
};
bool m_is_error { false }; bool m_is_error { false };
bool m_have_storage { false }; bool m_have_storage { false };
}; };