fixed gamelist diff calculations to be O(1) instead of O(n)
This commit is contained in:
parent
08193ff6a8
commit
cda5fbe22c
3 changed files with 9 additions and 5 deletions
|
@ -429,7 +429,12 @@ config::all_children_iterator config::ordered_end() const
|
|||
config config::get_diff(const config& c) const
|
||||
{
|
||||
config res;
|
||||
get_diff(c, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
void config::get_diff(const config& c, config& res) const
|
||||
{
|
||||
config* inserts = NULL;
|
||||
|
||||
string_map::const_iterator i;
|
||||
|
@ -530,9 +535,6 @@ config config::get_diff(const config& c) const
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void config::apply_diff(const config& diff)
|
||||
|
|
|
@ -145,6 +145,7 @@ public:
|
|||
//! I.e. calling cfg2.apply_diff(cfg1.get_diff(cfg2))
|
||||
//! will make cfg1 identical to cfg2.
|
||||
config get_diff(const config& c) const;
|
||||
void get_diff(const config& c, config& res) const;
|
||||
|
||||
void apply_diff(const config& diff); //throw error
|
||||
|
||||
|
|
|
@ -272,8 +272,9 @@ bool server::is_ip_banned(const std::string& ip) const {
|
|||
|
||||
config server::games_and_users_list_diff() {
|
||||
config res;
|
||||
res.add_child("gamelist_diff",games_and_users_list_.get_diff(old_games_and_users_list_));
|
||||
old_games_and_users_list_ = games_and_users_list_;
|
||||
config& diff = res.add_child("gamelist_diff");
|
||||
games_and_users_list_.get_diff(old_games_and_users_list_, diff);
|
||||
old_games_and_users_list_.apply_diff(diff);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue