Skip to content

Commit c31afa7

Browse files
committed
Remove unnecessary init from fast path
1 parent 013d8b3 commit c31afa7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/snmalloc/ds_core/redblacktree.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ namespace snmalloc
101101
H ptr;
102102

103103
public:
104-
ChildRef() : ptr(nullptr) {}
104+
constexpr ChildRef() = default;
105105

106106
ChildRef(H p) : ptr(p) {}
107107

@@ -232,7 +232,14 @@ namespace snmalloc
232232
struct RBStep
233233
{
234234
ChildRef node;
235-
bool dir = false;
235+
bool dir;
236+
237+
// Default constructor needed for Array<RBStep, 128>.
238+
constexpr RBStep() = default;
239+
240+
// Remove copy constructors to avoid accidentally copying and mutating the path.
241+
RBStep(const RBStep& other) = delete;
242+
RBStep& operator=(const RBStep& other) = delete;
236243

237244
/**
238245
* Update the step to point to a new node and direction.

src/snmalloc/mem/metadata.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ namespace snmalloc
282282
uintptr_t* val;
283283

284284
public:
285+
/**
286+
* Uninitialised constructor.
287+
*/
288+
BackendStateWordRef() = default;
289+
285290
/**
286291
* Constructor, wraps a `uintptr_t`. Note that this may be used outside
287292
* of the meta entry by code wishing to provide uniform storage to things

0 commit comments

Comments
 (0)