Simplify constant FlatHashSet initialization.

This commit is contained in:
levlam 2023-05-18 02:03:39 +03:00
parent 7bea39b6fa
commit f3a1407f8f
2 changed files with 9 additions and 7 deletions

View File

@ -1310,13 +1310,8 @@ static Slice fix_url(Slice str) {
}
const FlatHashSet<Slice, SliceHash> &get_valid_short_usernames() {
static const FlatHashSet<Slice, SliceHash> valid_usernames = [] {
FlatHashSet<Slice, SliceHash> result;
for (auto username : {"gif", "wiki", "vid", "bing", "pic", "bold", "imdb", "coub", "like", "vote"}) {
result.insert(Slice(username));
}
return result;
}();
static const FlatHashSet<Slice, SliceHash> valid_usernames{"gif", "wiki", "vid", "bing", "pic",
"bold", "imdb", "coub", "like", "vote"};
return valid_usernames;
}

View File

@ -226,6 +226,13 @@ class FlatHashTable {
used_node_count_ = used_nodes;
}
template <class T>
FlatHashTable(std::initializer_list<T> keys) {
for (auto &key : keys) {
emplace(KeyT(key));
}
}
FlatHashTable(FlatHashTable &&other) noexcept
: nodes_(other.nodes_)
, used_node_count_(other.used_node_count_)