From fbc73e20784b055485f676096e758d6aeed62e0c Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 1 Nov 2014 18:17:04 +0100 Subject: Add stdalgo::erase() and use it to simplify code --- src/modules/m_callerid.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/modules/m_callerid.cpp') diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index f15760dca..7f615494b 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -136,10 +136,7 @@ struct CallerIDExtInfo : public ExtensionItem continue; // shouldn't happen, but oh well. } - std::list::iterator it2 = std::find(targ->wholistsme.begin(), targ->wholistsme.end(), dat); - if (it2 != targ->wholistsme.end()) - targ->wholistsme.erase(it2); - else + if (!stdalgo::erase(targ->wholistsme, dat)) ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "ERROR: Inconsistency detected in callerid state, please report (2)"); } delete dat; @@ -323,11 +320,7 @@ public: return false; } - std::list::iterator it = std::find(dat2->wholistsme.begin(), dat2->wholistsme.end(), dat); - if (it != dat2->wholistsme.end()) - // Found me! - dat2->wholistsme.erase(it); - else + if (!stdalgo::erase(dat2->wholistsme, dat)) ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "ERROR: Inconsistency detected in callerid state, please report (4)"); -- cgit v1.3.1-10-gc9f91