convergedcallengine/cce/src/cccepluginmanager.cpp
branchRCL_3
changeset 19 7d48bed6ce0c
parent 0 ff3b6d0fd310
child 20 987c9837762f
--- a/convergedcallengine/cce/src/cccepluginmanager.cpp	Thu Aug 19 10:28:14 2010 +0300
+++ b/convergedcallengine/cce/src/cccepluginmanager.cpp	Tue Aug 31 15:45:17 2010 +0300
@@ -73,10 +73,10 @@
 #if 0
 // capabilities still todo here
 
-	static _LIT_SECURITY_POLICY_PASS( KAllowAllPolicy );
-	static _LIT_SECURITY_POLICY_C2(	KICMPolicy, 
-									ECapabilityNetworkControl,
-									ECapabilityWriteDeviceData);	
+    static _LIT_SECURITY_POLICY_PASS( KAllowAllPolicy );
+    static _LIT_SECURITY_POLICY_C2( KICMPolicy, 
+                                    ECapabilityNetworkControl,
+                                    ECapabilityWriteDeviceData);    
 
         
     // define first property to be integer type
@@ -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;
             }
         }
     }