improved efficiency of network code...
...by avoiding deep copy of every incoming config object
This commit is contained in:
parent
4083cd139f
commit
058fb986bd
3 changed files with 11 additions and 1 deletions
|
@ -782,6 +782,13 @@ std::string config::hash() const
|
|||
return std::string(hash_str);
|
||||
}
|
||||
|
||||
void config::swap(config& cfg)
|
||||
{
|
||||
values.swap(cfg.values);
|
||||
children.swap(cfg.children);
|
||||
ordered_children.swap(cfg.ordered_children);
|
||||
}
|
||||
|
||||
bool operator==(const config& a, const config& b)
|
||||
{
|
||||
if (a.values != b.values)
|
||||
|
|
|
@ -168,6 +168,9 @@ public:
|
|||
//! Resets the translated values of all strings contained in this object
|
||||
void reset_translation() const;
|
||||
|
||||
//this is a cheap O(1) operation
|
||||
void swap(config& cfg);
|
||||
|
||||
//! All the attributes of this node.
|
||||
string_map values;
|
||||
|
||||
|
|
|
@ -625,7 +625,7 @@ TCPsocket get_received_data(TCPsocket sock, config& cfg)
|
|||
delete buf;
|
||||
throw config::error(error);
|
||||
} else {
|
||||
cfg = (*itor)->config_buf;
|
||||
cfg.swap((*itor)->config_buf);
|
||||
const TCPsocket res = (*itor)->sock;
|
||||
buffer* buf = *itor;
|
||||
received_data_queue.erase(itor);
|
||||
|
|
Loading…
Add table
Reference in a new issue