diff --git a/td/telegram/OptionManager.cpp b/td/telegram/OptionManager.cpp index 27ccde50c..6ff9a0fc3 100644 --- a/td/telegram/OptionManager.cpp +++ b/td/telegram/OptionManager.cpp @@ -60,6 +60,7 @@ OptionManager::OptionManager(Td *td) all_options["utc_time_offset"] = PSTRING() << 'I' << Clocks::tz_offset(); for (const auto &name_value : all_options) { const string &name = name_value.first; + CHECK(!name.empty()); options_->set(name, name_value.second); if (!is_internal_option(name)) { send_closure(G()->td(), &Td::send_update, diff --git a/tddb/td/db/SeqKeyValue.h b/tddb/td/db/SeqKeyValue.h index 9870ac939..b12975cfb 100644 --- a/tddb/td/db/SeqKeyValue.h +++ b/tddb/td/db/SeqKeyValue.h @@ -6,11 +6,9 @@ // #pragma once -#include "td/utils/HashTableUtils.h" +#include "td/utils/FlatHashMap.h" #include "td/utils/Slice.h" -#include - namespace td { class SeqKeyValue { @@ -24,6 +22,7 @@ class SeqKeyValue { ~SeqKeyValue() = default; SeqNo set(Slice key, Slice value) { + CHECK(!key.empty()); auto it_ok = map_.emplace(key.str(), value.str()); if (!it_ok.second) { if (it_ok.first->second == value) { @@ -84,13 +83,19 @@ class SeqKeyValue { return map_.size(); } - std::unordered_map> get_all() const { - return map_; + FlatHashMap get_all() const { + FlatHashMap result; + result.reserve(map_.size()); + for (auto &it : map_) { + result.emplace(it.first, it.second); + } + return result; } private: - std::unordered_map> map_; + FlatHashMap map_; SeqNo current_id_ = 0; + SeqNo next_seq_no() { return ++current_id_; } diff --git a/tddb/td/db/TsSeqKeyValue.h b/tddb/td/db/TsSeqKeyValue.h index ebb413289..ec56b9738 100644 --- a/tddb/td/db/TsSeqKeyValue.h +++ b/tddb/td/db/TsSeqKeyValue.h @@ -8,11 +8,10 @@ #include "td/db/SeqKeyValue.h" -#include "td/utils/HashTableUtils.h" +#include "td/utils/FlatHashMap.h" #include "td/utils/port/RwMutex.h" #include "td/utils/Slice.h" -#include #include namespace td { @@ -69,7 +68,7 @@ class TsSeqKeyValue { return kv_.size(); } - std::unordered_map> get_all() const { + FlatHashMap get_all() const { auto lock = rw_mutex_.lock_write().move_as_ok(); return kv_.get_all(); }