convergedcallengine/cce/src/cccepluginmanager.cpp
branchGCC_SURGE
changeset 34 8ed2e80af9dd
parent 31 a2467631ae02
--- a/convergedcallengine/cce/src/cccepluginmanager.cpp	Tue Jun 15 11:45:07 2010 +0100
+++ b/convergedcallengine/cce/src/cccepluginmanager.cpp	Thu Jul 22 16:38:43 2010 +0100
@@ -471,7 +471,7 @@
     else if( iAlternativeEmergencyPlugins.Find( aUid ) == KErrNotFound )
         {
         CCELOGSTRING("CCCEPluginManager::AddToAlternativeEmergencyArray: New plugin. Append to array ");    
-        iAlternativeEmergencyPlugins.Append( aUid );  
+        iAlternativeEmergencyPlugins.Append( aUid );  // return value ignored..
         }    
     else
         {
@@ -609,12 +609,16 @@
     {
     CCCEPlugin* plugin( NULL );
     
-    for( TInt i=0; i<iPluginArray.Count(); i++ )
+    // performance note: a loop is nothing but keeping count in a register, decrementing it's
+    // value after each iteration and jumping back.
+    // But, calling RPointerArray.Count() is expensive.. that's why const TInt count
+    const TInt count = iPluginArray.Count();
+    for( TInt i=0; i < count; i++ )
         {
         if( iPluginArray[i]->Type().iUid == aImplementationUid.iUid )
             {
             plugin =  iPluginArray[i];
-            i = iPluginArray.Count();
+            i = count;
             }
         }
   
@@ -656,14 +660,16 @@
         {
         if ( iPluginArray[a]->Type() == aPluginId )
             {
-            iPluginsToClose.Append(iPluginArray[a]);
-            if (!iIdle->IsActive())
-                {
-                iIdle->Start( TCallBack(RemovePlugins,this) );
+            if( KErrNone == iPluginsToClose.Append(iPluginArray[a]))
+                {          
+                if (!iIdle->IsActive())
+                    {
+                    iIdle->Start( TCallBack(RemovePlugins,this) );
+                    }
+                iPluginArray.Remove(a);
+                iPluginArray.Compress();
+                return;
                 }
-            iPluginArray.Remove(a);
-            iPluginArray.Compress();
-            return;
             }
         }
     }
@@ -688,14 +694,16 @@
         {
         if ( iPluginArray[a]->Type() == aPluginUid )
             {
-            iPluginsToClose.Append(iPluginArray[a]);
-            if (!iIdle->IsActive())
-                {
-                iIdle->Start( TCallBack(RemovePlugins,this) );
+            if( KErrNone == iPluginsToClose.Append(iPluginArray[a]))
+                {          
+                if (!iIdle->IsActive())
+                    {
+                    iIdle->Start( TCallBack(RemovePlugins,this) );
+                    }
+                iPluginArray.Remove(a);
+                iPluginArray.Compress();
+                return;
                 }
-            iPluginArray.Remove(a);
-            iPluginArray.Compress();
-            return;
             }
         }
     }