Author: dave
Date: Sun Mar 9 21:43:37 2008
New Revision: 24456
URL: http://svn.gna.org/viewcvs/wesnoth?rev=24456&view=rev
Log:
improved efficiency of network code by avoiding deep copy of every incoming
config object
Modified:
trunk/src/config.cpp
trunk/src/config.hpp
trunk/src/network_worker.cpp
Modified: trunk/src/config.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/config.cpp?rev=24456&r1=24455&r2=24456&view=diff
==============================================================================
--- trunk/src/config.cpp (original)
+++ trunk/src/config.cpp Sun Mar 9 21:43:37 2008
@@ -782,6 +782,13 @@
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)
Modified: trunk/src/config.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/config.hpp?rev=24456&r1=24455&r2=24456&view=diff
==============================================================================
--- trunk/src/config.hpp (original)
+++ trunk/src/config.hpp Sun Mar 9 21:43:37 2008
@@ -168,6 +168,9 @@
//! 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;
Modified: trunk/src/network_worker.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/network_worker.cpp?rev=24456&r1=24455&r2=24456&view=diff
==============================================================================
--- trunk/src/network_worker.cpp (original)
+++ trunk/src/network_worker.cpp Sun Mar 9 21:43:37 2008
@@ -625,7 +625,7 @@
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);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits