File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ OptionManager::OptionManager(Td *td)
6060 all_options[" utc_time_offset" ] = PSTRING () << ' I' << Clocks::tz_offset ();
6161 for (const auto &name_value : all_options) {
6262 const string &name = name_value.first ;
63+ CHECK (!name.empty ());
6364 options_->set (name, name_value.second );
6465 if (!is_internal_option (name)) {
6566 send_closure (G ()->td (), &Td::send_update,
Original file line number Diff line number Diff line change 66//
77#pragma once
88
9- #include " td/utils/HashTableUtils .h"
9+ #include " td/utils/FlatHashMap .h"
1010#include " td/utils/Slice.h"
1111
12- #include < unordered_map>
13-
1412namespace td {
1513
1614class SeqKeyValue {
@@ -24,6 +22,7 @@ class SeqKeyValue {
2422 ~SeqKeyValue () = default ;
2523
2624 SeqNo set (Slice key, Slice value) {
25+ CHECK (!key.empty ());
2726 auto it_ok = map_.emplace (key.str (), value.str ());
2827 if (!it_ok.second ) {
2928 if (it_ok.first ->second == value) {
@@ -84,13 +83,19 @@ class SeqKeyValue {
8483 return map_.size ();
8584 }
8685
87- std::unordered_map<string, string, Hash<string>> get_all () const {
88- return map_;
86+ FlatHashMap<string, string> get_all () const {
87+ FlatHashMap<string, string> result;
88+ result.reserve (map_.size ());
89+ for (auto &it : map_) {
90+ result.emplace (it.first , it.second );
91+ }
92+ return result;
8993 }
9094
9195 private:
92- std::unordered_map <string, string, Hash<string> > map_;
96+ FlatHashMap <string, string> map_;
9397 SeqNo current_id_ = 0 ;
98+
9499 SeqNo next_seq_no () {
95100 return ++current_id_;
96101 }
Original file line number Diff line number Diff line change 88
99#include " td/db/SeqKeyValue.h"
1010
11- #include " td/utils/HashTableUtils .h"
11+ #include " td/utils/FlatHashMap .h"
1212#include " td/utils/port/RwMutex.h"
1313#include " td/utils/Slice.h"
1414
15- #include < unordered_map>
1615#include < utility>
1716
1817namespace td {
@@ -69,7 +68,7 @@ class TsSeqKeyValue {
6968 return kv_.size ();
7069 }
7170
72- std::unordered_map <string, string, Hash<string> > get_all () const {
71+ FlatHashMap <string, string> get_all () const {
7372 auto lock = rw_mutex_.lock_write ().move_as_ok ();
7473 return kv_.get_all ();
7574 }
You can’t perform that action at this time.
0 commit comments