From 711e33b9f8461df55c2fa8e5351769c6e6eb3e0f Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 16 Dec 2014 16:42:35 +0100 Subject: Change listmode storage type to vector --- include/listmode.h | 2 +- src/listmode.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/listmode.h b/include/listmode.h index 04044948c..94af1d524 100644 --- a/include/listmode.h +++ b/include/listmode.h @@ -37,7 +37,7 @@ class CoreExport ListModeBase : public ModeHandler /** Items stored in the channel's list */ - typedef std::list ModeList; + typedef std::vector ModeList; private: class ChanData diff --git a/src/listmode.cpp b/src/listmode.cpp index 19f2d6061..4e2b95e7d 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -192,7 +192,7 @@ ModeAction ListModeBase::OnModeChange(User* source, User*, Channel* channel, std { if (parameter == it->mask) { - cd->list.erase(it); + stdalgo::vector::swaperase(cd->list, it); return MODEACTION_ALLOW; } } -- cgit v1.2.3 From b2d890f6d81b42db0edcbce5a385b881cdfbc5ac Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 16 Dec 2014 16:44:00 +0100 Subject: Display listmodes in the order in which they are in the container instead of reverse iterating --- src/listmode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/listmode.cpp b/src/listmode.cpp index 4e2b95e7d..3feb42777 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -32,7 +32,7 @@ void ListModeBase::DisplayList(User* user, Channel* channel) ChanData* cd = extItem.get(channel); if (cd) { - for (ModeList::reverse_iterator it = cd->list.rbegin(); it != cd->list.rend(); ++it) + for (ModeList::const_iterator it = cd->list.begin(); it != cd->list.end(); ++it) { user->WriteNumeric(listnumeric, "%s %s %s %lu", channel->name.c_str(), it->mask.c_str(), (!it->setter.empty() ? it->setter.c_str() : ServerInstance->Config->ServerName.c_str()), (unsigned long) it->time); } -- cgit v1.2.3 From 64ccea389cc5a71badc9f8d0ea6731750ed4fde6 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Tue, 16 Dec 2014 16:45:06 +0100 Subject: Drop setter is empty check when displaying listmodes The setter cannot be empty unless the nick of a client is empty which is not possible --- src/listmode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/listmode.cpp b/src/listmode.cpp index 3feb42777..1147a4ef2 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -34,7 +34,7 @@ void ListModeBase::DisplayList(User* user, Channel* channel) { for (ModeList::const_iterator it = cd->list.begin(); it != cd->list.end(); ++it) { - user->WriteNumeric(listnumeric, "%s %s %s %lu", channel->name.c_str(), it->mask.c_str(), (!it->setter.empty() ? it->setter.c_str() : ServerInstance->Config->ServerName.c_str()), (unsigned long) it->time); + user->WriteNumeric(listnumeric, "%s %s %s %lu", channel->name.c_str(), it->mask.c_str(), it->setter.c_str(), (unsigned long) it->time); } } user->WriteNumeric(endoflistnumeric, "%s :%s", channel->name.c_str(), endofliststring.c_str()); -- cgit v1.2.3