[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/kopete/chatwindow
From:       Aleix Pol Gonzalez <aleixpol () gmail ! com>
Date:       2009-08-24 1:22:52
Message-ID: 1251076972.717606.18033.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1014851 by apol:

Properly iterate through the maps to remove the items. We don't have to copy the \
iterator that way, we don't have to allocate unneeded . If we are going to delete \
ourselves the KMenu, let's stack it, let's let the compiler to allocate himself \
(which means to use the stack). It is a microoptimization but makes the code cleaner, \
IMHO.


 M  +22 -23    kopetechatwindow.cpp  


--- trunk/KDE/kdenetwork/kopete/kopete/chatwindow/kopetechatwindow.cpp \
#1014850:1014851 @@ -285,26 +285,26 @@
 
 	for( AccountMap::Iterator it = accountMap.begin(); it != accountMap.end(); )
 	{
-		AccountMap::Iterator mayDeleteIt = it;
-		++it;
-		if( mayDeleteIt.value() == this )
-			accountMap.remove( mayDeleteIt.key() );
+		if( it.value() == this )
+			it=accountMap.erase( it );
+		else
+			++it;
 	}
 
 	for( GroupMap::Iterator it = groupMap.begin(); it != groupMap.end(); )
 	{
-		GroupMap::Iterator mayDeleteIt = it;
-		++it;
-		if( mayDeleteIt.value() == this )
-			groupMap.remove( mayDeleteIt.key() );
+		if( it.value() == this )
+			it=groupMap.erase( it );
+		else
+			++it;
 	}
 
 	for( MetaContactMap::Iterator it = mcMap.begin(); it != mcMap.end(); )
 	{
-		MetaContactMap::Iterator mayDeleteIt = it;
-		++it;
-		if( mayDeleteIt.value() == this )
-			mcMap.remove( mayDeleteIt.key() );
+		if( it.value() == this )
+			it=mcMap.erase( it );
+		else
+			++it;
 	}
 
 	windows.removeAt( windows.indexOf( this ) );
@@ -330,18 +330,17 @@
 {
 	m_popupView = static_cast<ChatView*>( tab );
 
-	KMenu *popup = new KMenu;
-	popup->addTitle( KStringHandler::rsqueeze( m_popupView->caption() ) );
-	popup->addAction( actionContactMenu );
-	popup->addSeparator();
-	popup->addAction( actionTabPlacementMenu );
-	popup->addAction( tabDetach );
-	popup->addAction( actionDetachMenu );
-	popup->addAction( tabCloseAllOthers );
-	popup->addAction( tabClose );
-	popup->exec( pos );
+	KMenu popup;
+	popup.addTitle( KStringHandler::rsqueeze( m_popupView->caption() ) );
+	popup.addAction( actionContactMenu );
+	popup.addSeparator();
+	popup.addAction( actionTabPlacementMenu );
+	popup.addAction( tabDetach );
+	popup.addAction( actionDetachMenu );
+	popup.addAction( tabCloseAllOthers );
+	popup.addAction( tabClose );
+	popup.exec( pos );
 
-	delete popup;
 	m_popupView = 0;
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic