Remove unneeded FlatHashTable copy constructors.

This commit is contained in:
levlam 2022-07-23 11:13:17 +03:00
parent bc83832e03
commit 36a57c3584
2 changed files with 3 additions and 42 deletions

View File

@ -198,13 +198,8 @@ class FlatHashTable {
};
FlatHashTable() = default;
FlatHashTable(const FlatHashTable &other) {
assign(other);
}
void operator=(const FlatHashTable &other) {
clear();
assign(other);
}
FlatHashTable(const FlatHashTable &other) = delete;
FlatHashTable &operator=(const FlatHashTable &other) = delete;
FlatHashTable(std::initializer_list<NodeT> nodes) {
if (nodes.size() == 0) {
@ -249,9 +244,7 @@ class FlatHashTable {
other.drop();
}
~FlatHashTable() {
if (nodes_ != nullptr) {
clear_nodes(nodes_);
}
clear_nodes(nodes_);
}
void swap(FlatHashTable &other) noexcept {
@ -433,30 +426,6 @@ class FlatHashTable {
begin_bucket_ = 0;
}
void assign(const FlatHashTable &other) {
if (other.size() == 0) {
return;
}
resize(other.bucket_count());
auto other_nodes_end = other.nodes_ + other.bucket_count_;
for (const NodeT *other_node = other.nodes_; other_node != other_nodes_end; ++other_node) {
if (other_node->empty()) {
continue;
}
auto bucket = calc_bucket(other_node->key());
while (true) {
auto &node = nodes_[bucket];
if (node.empty()) {
node.copy_from(*other_node);
break;
}
next_bucket(bucket);
}
}
used_node_count_ = other.used_node_count_;
}
NodeT *begin_impl() {
if (empty()) {
return nullptr;

View File

@ -124,7 +124,6 @@ TEST(FlatHashMap, basic) {
ASSERT_EQ(2, kv.second);
}
map.erase(map.find(1));
auto map_copy = map;
}
td::FlatHashMap<int, std::array<td::unique_ptr<td::string>, 10>> x;
@ -159,9 +158,6 @@ TEST(FlatHashMap, basic) {
}
ASSERT_EQ(data, extract_kv(kv));
KV copied_kv(kv);
ASSERT_EQ(data, extract_kv(copied_kv));
KV moved_kv(std::move(kv));
ASSERT_EQ(data, extract_kv(moved_kv));
ASSERT_EQ(Data{}, extract_kv(kv));
@ -169,10 +165,6 @@ TEST(FlatHashMap, basic) {
kv = std::move(moved_kv);
ASSERT_EQ(data, extract_kv(kv));
KV assign_copied_kv;
assign_copied_kv = kv;
ASSERT_EQ(data, extract_kv(assign_copied_kv));
KV assign_moved_kv;
assign_moved_kv = std::move(kv);
ASSERT_EQ(data, extract_kv(assign_moved_kv));