Skip to content

Commit

Permalink
I thought the {} does the initialization, but let’s be sure.
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed Jan 11, 2024
1 parent 2c64d67 commit f390d17
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion benchmarks/C++/src/som/dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,17 @@ class Dictionary {
uint32_t _size{0};
uint32_t _capacity;

static Entry** createInitialized(uint32_t capacity) {
auto* buckets = new Entry* [capacity] {};
for (uint32_t i = 0; i < capacity; i += 1) {
buckets[i] = nullptr;
}
return buckets;
}

public:
explicit Dictionary(uint32_t capacity = INITIAL_CAPACITY)
: _buckets(new Entry* [capacity] {}), _capacity(capacity) {}
: _buckets(createInitialized(capacity)), _capacity(capacity) {}

virtual ~Dictionary() {
removeAll();
Expand Down

0 comments on commit f390d17

Please sign in to comment.