From 9936cb5ae7eaf8907cbff5722b206087b18053ca Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 9 Feb 2011 15:14:05 +0100 Subject: [PATCH] Use a vector for sent_comm (smaller and faster than a list). --- communicator.cpp | 5 ++++- communicator.h | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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; -- 2.39.5