From: Arnaud Giersch Date: Wed, 9 Feb 2011 14:14:05 +0000 (+0100) Subject: Use a vector for sent_comm (smaller and faster than a list). X-Git-Tag: v0.1~153 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/9936cb5ae7eaf8907cbff5722b206087b18053ca Use a vector for sent_comm (smaller and faster than a list). --- diff --git a/communicator.cpp b/communicator.cpp index daf1434..ce0e79f 100644 --- a/communicator.cpp +++ b/communicator.cpp @@ -60,7 +60,10 @@ void communicator::send(const char* dest, message* msg) void communicator::flush(bool wait) { - sent_comm.remove_if(comm_test_n_destroy); + sent_comm_type::iterator bound; + bound = std::remove_if(sent_comm.begin(), sent_comm.end(), + comm_test_n_destroy); + sent_comm.erase(bound, sent_comm.end()); if (wait && !sent_comm.empty()) { msg_comm_t comms[sent_comm.size()]; std::copy(sent_comm.begin(), sent_comm.end(), comms); diff --git a/communicator.h b/communicator.h index cfe8624..ce74f07 100644 --- a/communicator.h +++ b/communicator.h @@ -3,7 +3,7 @@ #ifndef COMMUNICATOR_H #define COMMUNICATOR_H -#include +#include #include #include "hostdata.h" #include "messages.h" @@ -31,7 +31,8 @@ private: const hostdata* host; // List of pending send communications - std::list sent_comm; + typedef std::vector sent_comm_type; + sent_comm_type sent_comm; // Queue of received messages message_queue received;