diff --git a/src/Common/HashTable/HashTable.h b/src/Common/HashTable/HashTable.h index 5d4410ce4e7..06b4d74cfcb 100644 --- a/src/Common/HashTable/HashTable.h +++ b/src/Common/HashTable/HashTable.h @@ -341,6 +341,32 @@ struct ZeroValueStorage }; +template +struct AllocatorBufferDeleter; + +template +struct AllocatorBufferDeleter +{ + AllocatorBufferDeleter(Allocator &, size_t) {} + + void operator()(Cell *) const {} + +}; + +template +struct AllocatorBufferDeleter +{ + AllocatorBufferDeleter(Allocator & allocator_, size_t size_) + : allocator(allocator_) + , size(size_) {} + + void operator()(Cell * buffer) const { allocator.free(buffer, size); } + + Allocator & allocator; + size_t size; +}; + + // The HashTable template < @@ -434,35 +460,6 @@ protected: } } - template - struct AllocatorBufferDeleter; - - template<> - struct AllocatorBufferDeleter - { - AllocatorBufferDeleter(Allocator &, size_t) {} - - void operator()(Cell *) const {} - - }; - - template<> - struct AllocatorBufferDeleter - { - AllocatorBufferDeleter(Allocator & allocator_, size_t size_) - : allocator(allocator_) - , size(size_) - {} - - void operator()(Cell * buffer) const - { - allocator.free(buffer, size); - } - - Allocator & allocator; - size_t size; - }; - /// Increase the size of the buffer. void resize(size_t for_num_elems = 0, size_t for_buf_size = 0) { @@ -501,8 +498,9 @@ protected: /** If cell required to be notified during move we need to temporary keep old buffer * because realloc does not quarantee for reallocated buffer to have same base address */ - AllocatorBufferDeleter buffer_deleter(*this, old_buffer_size); - std::unique_ptr old_buffer(buf, buffer_deleter); + using Deleter = AllocatorBufferDeleter; + Deleter buffer_deleter(*this, old_buffer_size); + std::unique_ptr old_buffer(buf, buffer_deleter); if constexpr (Cell::need_to_notify_cell_during_move) { diff --git a/src/Common/tests/lru_hash_map_perf.cpp b/src/Common/tests/lru_hash_map_perf.cpp index f7ef1fdd759..14beff3f7da 100644 --- a/src/Common/tests/lru_hash_map_perf.cpp +++ b/src/Common/tests/lru_hash_map_perf.cpp @@ -142,7 +142,7 @@ void testInsertElementsIntoHashMap(size_t map_size, const std::vector & for (size_t i = 0; i < numbers_to_insert_size; ++i) { - auto it = hash_map.find(numbers_to_insert[i]); + auto * it = hash_map.find(numbers_to_insert[i]); if (it) summ += it->getMapped();