mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-09 01:51:30 +00:00
fixed gamelist diff calculations to be O(1) instead of O(n)
This commit is contained in:
parent
08193ff6a8
commit
cda5fbe22c
@ -429,7 +429,12 @@ config::all_children_iterator config::ordered_end() const
|
|||||||
config config::get_diff(const config& c) const
|
config config::get_diff(const config& c) const
|
||||||
{
|
{
|
||||||
config res;
|
config res;
|
||||||
|
get_diff(c, res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void config::get_diff(const config& c, config& res) const
|
||||||
|
{
|
||||||
config* inserts = NULL;
|
config* inserts = NULL;
|
||||||
|
|
||||||
string_map::const_iterator i;
|
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)
|
void config::apply_diff(const config& diff)
|
||||||
|
@ -145,6 +145,7 @@ public:
|
|||||||
//! I.e. calling cfg2.apply_diff(cfg1.get_diff(cfg2))
|
//! I.e. calling cfg2.apply_diff(cfg1.get_diff(cfg2))
|
||||||
//! will make cfg1 identical to cfg2.
|
//! will make cfg1 identical to cfg2.
|
||||||
config get_diff(const config& c) const;
|
config get_diff(const config& c) const;
|
||||||
|
void get_diff(const config& c, config& res) const;
|
||||||
|
|
||||||
void apply_diff(const config& diff); //throw error
|
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 server::games_and_users_list_diff() {
|
||||||
config res;
|
config res;
|
||||||
res.add_child("gamelist_diff",games_and_users_list_.get_diff(old_games_and_users_list_));
|
config& diff = res.add_child("gamelist_diff");
|
||||||
old_games_and_users_list_ = games_and_users_list_;
|
games_and_users_list_.get_diff(old_games_and_users_list_, diff);
|
||||||
|
old_games_and_users_list_.apply_diff(diff);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user