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] da099d4312/
This commit is contained in:
Florent Rougon
2018-01-08 10:26:18 +01:00
parent da099d4312
commit 455753c774

View File

@@ -32,10 +32,12 @@
#include <simgear_config.h>
#include "sg_netChannel.hxx"
#include <algorithm>
#include <memory>
#include <cassert>
#include <cerrno>
#include <cstring>
#include <errno.h>
#include <simgear/debug/logstream.hxx>
@@ -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);
}
}