metadataengine/client/src/mdeobjectdef.cpp
changeset 1 acef663c1218
parent 0 c53acadfccc6
child 3 6752808b2036
--- a/metadataengine/client/src/mdeobjectdef.cpp	Mon Jan 18 20:34:07 2010 +0200
+++ b/metadataengine/client/src/mdeobjectdef.cpp	Tue Jan 26 12:13:20 2010 +0200
@@ -59,7 +59,8 @@
         {
 		aSchemaBuffer.PositionL( propertyOffset + i * sizeof(TMdCPropertyDef) );
 		const TMdCPropertyDef& propertyDef = TMdCPropertyDef::GetFromBufferL(aSchemaBuffer);
-		iPropertyDefs.AppendL( CMdEPropertyDef::NewL( propertyDef, aSchemaBuffer, *this ) );
+		CMdEPropertyDef* propertyDefImpl = CMdEPropertyDef::NewL( propertyDef, aSchemaBuffer, *this );
+		iPropertyDefs.InsertInOrder( propertyDefImpl, TLinearOrder<CMdEPropertyDef>(CMdEObjectDef::CompareProperties) );
         }
     }
 
@@ -129,7 +130,7 @@
 	}
 
 CMdEPropertyDef* CMdEObjectDef::GetPropertyDefL( const TDesC& aName, CMdEObjectDef* aChild )
-    {
+    {    
     const TInt propertyDefCount = iPropertyDefs.Count();
     for ( TInt i = 0; i < propertyDefCount; ++i )
         {
@@ -156,16 +157,11 @@
 
 CMdEPropertyDef* CMdEObjectDef::GetPropertyDefL(TDefId aId, CMdEObjectDef* aChild)
     {
-    const TInt count = iPropertyDefs.Count();
+    const TInt i = iPropertyDefs.FindInOrder(aId, CMdEObjectDef::CompareProperties );
     
-    for ( TInt i = 0; i < count; ++i )
+    if (i >= 0 && i < iPropertyDefs.Count() && iPropertyDefs[i] )
         {
-        CMdEPropertyDef* propDef = iPropertyDefs[i];
-        
-        if( propDef && propDef->Id() == aId )
-        	{
-        	return propDef;
-        	}
+        return iPropertyDefs[i];
         }
 
     CMdEObjectDef* parent = ParentL();
@@ -192,3 +188,14 @@
 
 	return iPropertyDefs[aIndex];
 	}
+
+TInt CMdEObjectDef::CompareProperties( const CMdEPropertyDef& aFirst, const CMdEPropertyDef& aSecond )
+    {
+    return aFirst.Id() - aSecond.Id();
+    }
+
+TInt CMdEObjectDef::CompareProperties( const TDefId* aFirst, const CMdEPropertyDef& aSecond )
+    {
+    return *aFirst - aSecond.Id();
+    }
+