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

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2015-12-23 11:06:57 +01:00 committed by Alexandre Julliard
parent d3f7519035
commit 4cce8cbd5f
1 changed files with 11 additions and 11 deletions

View File

@ -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 );