From 74e86a289d74662385cc9632fd65a5dd8be8a00c Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 12 Oct 2020 20:06:43 -0400 Subject: [PATCH] Remove all instances from a collector when requested Perhaps COLLECTOR should use a set, but going for the less invasive change for now. Fixes https://gitlab.com/kicad/code/kicad/-/issues/5934 --- include/collector.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/include/collector.h b/include/collector.h index f755f711c1..d628d719ef 100644 --- a/include/collector.h +++ b/include/collector.h @@ -143,14 +143,12 @@ public: */ void Remove( const EDA_ITEM* aItem ) { - for( size_t i = 0; i < m_list.size(); i++ ) - { - if( m_list[i] == aItem ) - { - m_list.erase( m_list.begin() + i); - return; - } - } + m_list.erase( std::remove_if( m_list.begin(), m_list.end(), + [&aItem]( const EDA_ITEM* aCandidate ) + { + return aCandidate == aItem; + } ), + m_list.end() ); } /**