Skip to content

Commit 97758dc

Browse files
dp1martinus
authored andcommitted
avoid extra memset when clearing an empty table
1 parent fb13d8c commit 97758dc

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

include/ankerl/unordered_dense.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,8 +1536,10 @@ class table : public std::conditional_t<is_map_v<T>, base_table_type_map<T>, bas
15361536
// modifiers //////////////////////////////////////////////////////////////
15371537

15381538
void clear() {
1539-
m_values.clear();
1540-
clear_buckets();
1539+
if (!empty()) {
1540+
m_values.clear();
1541+
clear_buckets();
1542+
}
15411543
}
15421544

15431545
auto insert(value_type const& value) -> std::pair<iterator, bool> {

0 commit comments

Comments
 (0)