Commit 4cce8cbd authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wbemdisp: Calculate the object count returned from ISWbemObjectSet::get_Count just once.

parent d3f75190
......@@ -356,6 +356,7 @@ struct objectset
ISWbemObjectSet ISWbemObjectSet_iface;
LONG refs;
IEnumWbemClassObject *objectenum;
LONG count;
};
static inline struct objectset *impl_from_ISWbemObjectSet(
......@@ -517,20 +518,10 @@ static HRESULT WINAPI objectset_get_Count(
LONG *iCount )
{
struct objectset *objectset = impl_from_ISWbemObjectSet( iface );
LONG count = 0, total = 0;
TRACE( "%p, %p\n", objectset, iCount );
while (IEnumWbemClassObject_Skip( objectset->objectenum, WBEM_INFINITE, 1 ) == S_OK) count++;
IEnumWbemClassObject_Reset( objectset->objectenum );
while (IEnumWbemClassObject_Skip( objectset->objectenum, WBEM_INFINITE, 1 ) == S_OK) total++;
count = total - count;
IEnumWbemClassObject_Reset( objectset->objectenum );
while (count--) IEnumWbemClassObject_Skip( objectset->objectenum, WBEM_INFINITE, 1 );
*iCount = total;
*iCount = objectset->count;
return S_OK;
}
......@@ -567,6 +558,14 @@ static const ISWbemObjectSetVtbl objectset_vtbl =
objectset_ItemIndex
};
static LONG get_object_count( IEnumWbemClassObject *iter )
{
LONG count = 0;
while (IEnumWbemClassObject_Skip( iter, WBEM_INFINITE, 1 ) == S_OK) count++;
IEnumWbemClassObject_Reset( iter );
return count;
}
static HRESULT SWbemObjectSet_create( IEnumWbemClassObject *wbem_objectenum, ISWbemObjectSet **obj )
{
struct objectset *objectset;
......@@ -578,6 +577,7 @@ static HRESULT SWbemObjectSet_create( IEnumWbemClassObject *wbem_objectenum, ISW
objectset->refs = 1;
objectset->objectenum = wbem_objectenum;
IEnumWbemClassObject_AddRef( objectset->objectenum );
objectset->count = get_object_count( objectset->objectenum );
*obj = &objectset->ISWbemObjectSet_iface;
TRACE( "returning iface %p\n", *obj );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment