Forráskód Böngészése

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.
Tom 4 éve
szülő
commit
1d843c46eb
1 módosított fájl, 4 hozzáadás és 2 törlés
  1. 4 2
      Kernel/KResult.h

+ 4 - 2
Kernel/KResult.h

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