From 455753c77476bc3e8922a85be56a357bff709602 Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Mon, 8 Jan 2018 10:26:18 +0100 Subject: [PATCH] Simplify code in NetChannelPoller::removeChannel() Remove an apparently bogus portability workaround (which was presumably targetting one of the bugs fixed in the previous commit [1]) and further simplify the code using std::find(). [1] https://sourceforge.net/p/flightgear/simgear/ci/da099d431268f2ab1084f332f4331a64758b902f/ --- simgear/io/sg_netChannel.cxx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/simgear/io/sg_netChannel.cxx b/simgear/io/sg_netChannel.cxx index a4a3d221..44673e11 100644 --- a/simgear/io/sg_netChannel.cxx +++ b/simgear/io/sg_netChannel.cxx @@ -32,10 +32,12 @@ #include #include "sg_netChannel.hxx" +#include #include + #include +#include #include -#include #include @@ -258,18 +260,10 @@ NetChannelPoller::removeChannel(NetChannel* channel) assert(channel); assert(channel->poller == this); channel->poller = NULL; - - // portability: MSVC throws assertion failure when empty - if (channels.empty()) { - return; - } - ChannelList::iterator it = channels.begin(); - for (; it != channels.end(); ++it) { - if (*it == channel) { - channels.erase(it); - return; - } + auto it = std::find(channels.begin(), channels.end(), channel); + if (it != channels.end()) { + channels.erase(it); } }