kern: avoid constexpr init for many objects (avoids unnecessary memory clear) (#1668)
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#pragma once
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
#include <vapours/util/util_type_traits.hpp>
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize ("-O3")
|
||||
@@ -57,11 +58,14 @@ namespace ams::freebsd {
|
||||
template<typename T>
|
||||
class RBEntry {
|
||||
private:
|
||||
T *m_rbe_left = nullptr;
|
||||
T *m_rbe_right = nullptr;
|
||||
T *m_rbe_parent = nullptr;
|
||||
RBColor m_rbe_color = RBColor::RB_BLACK;
|
||||
T *m_rbe_left ;
|
||||
T *m_rbe_right;
|
||||
T *m_rbe_parent;
|
||||
RBColor m_rbe_color;
|
||||
public:
|
||||
constexpr ALWAYS_INLINE explicit RBEntry(util::ConstantInitializeTag) : m_rbe_left(nullptr), m_rbe_right(nullptr), m_rbe_parent(nullptr), m_rbe_color(RBColor::RB_BLACK) { /* ... */ }
|
||||
explicit ALWAYS_INLINE RBEntry() { /* ... */ }
|
||||
|
||||
[[nodiscard]] constexpr ALWAYS_INLINE T *Left() { return m_rbe_left; }
|
||||
[[nodiscard]] constexpr ALWAYS_INLINE const T *Left() const { return m_rbe_left; }
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ namespace ams::util {
|
||||
private:
|
||||
RBEntry m_entry;
|
||||
public:
|
||||
constexpr ALWAYS_INLINE IntrusiveRedBlackTreeNode() = default;
|
||||
constexpr explicit ALWAYS_INLINE IntrusiveRedBlackTreeNode(util::ConstantInitializeTag) : m_entry(util::ConstantInitialize) { /* ... */ }
|
||||
explicit ALWAYS_INLINE IntrusiveRedBlackTreeNode() { /* ... */ }
|
||||
|
||||
[[nodiscard]] constexpr ALWAYS_INLINE RBEntry &GetRBEntry() { return m_entry; }
|
||||
[[nodiscard]] constexpr ALWAYS_INLINE const RBEntry &GetRBEntry() const { return m_entry; }
|
||||
@@ -544,6 +545,8 @@ namespace ams::util {
|
||||
template<class Derived>
|
||||
class alignas(void *) IntrusiveRedBlackTreeBaseNode : public IntrusiveRedBlackTreeNode {
|
||||
public:
|
||||
using IntrusiveRedBlackTreeNode::IntrusiveRedBlackTreeNode;
|
||||
|
||||
constexpr ALWAYS_INLINE Derived *GetPrev() { return static_cast< Derived *>(static_cast< IntrusiveRedBlackTreeBaseNode *>(impl::IntrusiveRedBlackTreeImpl::GetPrev(this))); }
|
||||
constexpr ALWAYS_INLINE const Derived *GetPrev() const { return static_cast<const Derived *>(static_cast<const IntrusiveRedBlackTreeBaseNode *>(impl::IntrusiveRedBlackTreeImpl::GetPrev(this))); }
|
||||
|
||||
|
||||
@@ -102,9 +102,8 @@ namespace ams::util {
|
||||
state2 ^= y;
|
||||
}
|
||||
public:
|
||||
constexpr TinyMT() : m_state() { /* ... */ }
|
||||
|
||||
/* Public API. */
|
||||
constexpr explicit TinyMT(util::ConstantInitializeTag) : m_state() { /* ... */ }
|
||||
explicit TinyMT() { /* ... */ }
|
||||
|
||||
/* Initialization. */
|
||||
void Initialize(u32 seed) {
|
||||
|
||||
@@ -23,4 +23,7 @@ namespace ams::util {
|
||||
template<typename T>
|
||||
using is_pod = std::bool_constant<std::is_standard_layout<T>::value && std::is_trivial<T>::value>;
|
||||
|
||||
struct ConstantInitializeTag final {};
|
||||
constexpr inline const ConstantInitializeTag ConstantInitialize{};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user