Author: mordante
Date: Wed Aug 13 17:54:26 2008
New Revision: 28554
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28554&view=rev
Log:
Fix some compilation problems due to unused variable.
Send const std::string by reference instead of a copy.
Modified:
trunk/src/network.cpp
trunk/src/network.hpp
Modified: trunk/src/network.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/network.cpp?rev=28554&r1=28553&r2=28554&view=diff
==============================================================================
--- trunk/src/network.cpp (original)
+++ trunk/src/network.cpp Wed Aug 13 17:54:26 2008
@@ -917,7 +917,7 @@
-static bandwidth_map::iterator add_bandwidth_entry(const std::string
packet_type)
+static bandwidth_map::iterator add_bandwidth_entry(const std::string&
packet_type)
{
time_t now = time(0);
struct tm * timeinfo = localtime(&now);
@@ -1002,14 +1002,14 @@
return ss.str();
}
-void add_bandwidth_out(const std::string packet_type, size_t len)
+void add_bandwidth_out(const std::string& packet_type, size_t len)
{
bandwidth_map::iterator itor = add_bandwidth_entry(packet_type);
itor->second.out_bytes += len;
++(itor->second.out_packets);
}
-void add_bandwidth_in(const std::string packet_type, size_t len)
+void add_bandwidth_in(const std::string& packet_type, size_t len)
{
bandwidth_map::iterator itor = add_bandwidth_entry(packet_type);
itor->second.in_bytes += len;
@@ -1022,8 +1022,13 @@
}
#endif
-void send_file(const std::string& filename, connection connection_num, const
std::string packet_type
- )
+void send_file(const std::string& filename, connection connection_num,
+#ifdef BANDWIDTH_MONITOR
+ const std::string& packet_type
+#else
+ const std::string&
+#endif
+ )
{
assert(connection_num > 0);
if(bad_sockets.count(connection_num) || bad_sockets.count(0)) {
@@ -1048,7 +1053,13 @@
//! @todo Note the gzipped parameter should be removed later, we want to send
//! all data gzipped. This can be done once the campaign server is also updated
//! to work with gzipped data.
-size_t send_data(const config& cfg, connection connection_num, const bool
gzipped, const std::string packet_type)
+size_t send_data(const config& cfg, connection connection_num, const bool
gzipped,
+#ifdef BANDWIDTH_MONITOR
+ const std::string& packet_type
+#else
+ const std::string&
+#endif
+ )
{
DBG_NW << "in send_data()...\n";
@@ -1091,8 +1102,7 @@
);
}
-void send_raw_data(const char* buf, int len, connection connection_num, const
std::string packet_type
- )
+void send_raw_data(const char* buf, int len, connection connection_num, const
std::string& packet_type)
{
if(len == 0) {
return;
@@ -1105,8 +1115,7 @@
if(!connection_num) {
for(sockets_list::const_iterator i = sockets.begin();
i != sockets.end(); ++i) {
- send_raw_data(buf, len, connection_num, packet_type
- );
+ send_raw_data(buf, len, connection_num, packet_type);
}
return;
}
@@ -1131,8 +1140,13 @@
}
//! @todo Note the gzipped parameter should be removed later.
-void send_data_all_except(const config& cfg, connection connection_num, const
bool gzipped, const std::string packet_type
- )
+void send_data_all_except(const config& cfg, connection connection_num, const
bool gzipped,
+#ifdef BANDWIDTH_MONITOR
+ const std::string& packet_type
+#else
+ const std::string&
+#endif
+ )
{
for(sockets_list::const_iterator i = sockets.begin(); i !=
sockets.end(); ++i) {
if(*i == connection_num) {
Modified: trunk/src/network.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/network.hpp?rev=28554&r1=28553&r2=28554&view=diff
==============================================================================
--- trunk/src/network.hpp (original)
+++ trunk/src/network.hpp Wed Aug 13 17:54:26 2008
@@ -134,8 +134,8 @@
std::string get_bandwidth_stats_all();
std::string get_bandwidth_stats(int hour);
-void add_bandwidth_out(const std::string packet_type, size_t len);
-void add_bandwidth_in(const std::string packet_type, size_t len);
+void add_bandwidth_out(const std::string& packet_type, size_t len);
+void add_bandwidth_in(const std::string& packet_type, size_t len);
struct bandwidth_in {
bandwidth_in(int len) : len_(len), type_("unknown") {}
~bandwidth_in();
@@ -181,14 +181,16 @@
#endif
);
-void send_file(const std::string&, connection, const std::string packet_type =
"unknown");
+void send_file(const std::string&, connection, const std::string& packet_type
= "unknown");
//! Function to send data down a given connection,
//! or broadcast to all peers if connection_num is 0.
//! Throws error.
-size_t send_data(const config& cfg, connection connection_num /*= 0*/, const
bool gzipped, const std::string packet_type = "unknown");
-
-void send_raw_data(const char* buf, int len, connection connection_num, const
std::string packet_type = "unknown");
+size_t send_data(const config& cfg, connection connection_num /*= 0*/,
+ const bool gzipped, const std::string& packet_type = "unknown");
+
+void send_raw_data(const char* buf, int len, connection connection_num,
+ const std::string& packet_type = "unknown");
//! Function to send any data that is in a connection's send_queue,
//! up to a maximum of 'max_size' bytes --
@@ -196,8 +198,8 @@
void process_send_queue(connection connection_num=0, size_t max_size=0);
//! Function to send data to all peers except 'connection_num'.
-void send_data_all_except(const config& cfg, connection connection_num, const
bool gzipped, const std::string packet_type = "unknown"
- );
+void send_data_all_except(const config& cfg, connection connection_num,
+ const bool gzipped, const std::string& packet_type = "unknown");
//! Function to get the remote ip address of a socket.
std::string ip_address(connection connection_num);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits