aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-07-30 23:14:05 +0200
committerest31 <MTest31@outlook.com>2015-07-31 01:01:00 +0200
commit05fe9ab2d4a4be252adb456b8bc14896939e4eb7 (patch)
treeed081dd09bceb897be11bc255516f0eb8c609efa /src
parenteb3aac20c879b9532cd3b678efb2126adcd07af7 (diff)
downloadminetest-05fe9ab2d4a4be252adb456b8bc14896939e4eb7.tar.gz
minetest-05fe9ab2d4a4be252adb456b8bc14896939e4eb7.tar.bz2
minetest-05fe9ab2d4a4be252adb456b8bc14896939e4eb7.zip
Small SendableMediaAnnouncement cleanup
-> Remove the SendableMediaAnnouncement struct -> Forge the packet directly in the m_media loop, spare one loop and the construction of a vector -> Use preincrement to spare iterator copies
Diffstat (limited to 'src')
-rw-r--r--src/server.cpp34
1 files changed, 6 insertions, 28 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 33cba17e5..70fe5ae2c 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -2330,44 +2330,22 @@ void Server::fillMediaCache()
}
}
-struct SendableMediaAnnouncement
-{
- std::string name;
- std::string sha1_digest;
-
- SendableMediaAnnouncement(const std::string &name_="",
- const std::string &sha1_digest_=""):
- name(name_),
- sha1_digest(sha1_digest_)
- {}
-};
-
void Server::sendMediaAnnouncement(u16 peer_id)
{
DSTACK(__FUNCTION_NAME);
- verbosestream<<"Server: Announcing files to id("<<peer_id<<")"
- <<std::endl;
-
- std::vector<SendableMediaAnnouncement> file_announcements;
-
- for (std::map<std::string, MediaInfo>::iterator i = m_media.begin();
- i != m_media.end(); i++){
- // Put in list
- file_announcements.push_back(
- SendableMediaAnnouncement(i->first, i->second.sha1_digest));
- }
+ verbosestream << "Server: Announcing files to id(" << peer_id << ")"
+ << std::endl;
// Make packet
std::ostringstream os(std::ios_base::binary);
NetworkPacket pkt(TOCLIENT_ANNOUNCE_MEDIA, 0, peer_id);
- pkt << (u16) file_announcements.size();
+ pkt << (u16) m_media.size();
- for (std::vector<SendableMediaAnnouncement>::iterator
- j = file_announcements.begin();
- j != file_announcements.end(); ++j) {
- pkt << j->name << j->sha1_digest;
+ for (std::map<std::string, MediaInfo>::iterator i = m_media.begin();
+ i != m_media.end(); ++i) {
+ pkt << i->first << i->second.sha1_digest;
}
pkt << g_settings->get("remote_media");