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:
parent
d3f7519035
commit
4cce8cbd5f
|
@ -356,6 +356,7 @@ struct objectset
|
||||||
ISWbemObjectSet ISWbemObjectSet_iface;
|
ISWbemObjectSet ISWbemObjectSet_iface;
|
||||||
LONG refs;
|
LONG refs;
|
||||||
IEnumWbemClassObject *objectenum;
|
IEnumWbemClassObject *objectenum;
|
||||||
|
LONG count;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct objectset *impl_from_ISWbemObjectSet(
|
static inline struct objectset *impl_from_ISWbemObjectSet(
|
||||||
|
@ -517,20 +518,10 @@ static HRESULT WINAPI objectset_get_Count(
|
||||||
LONG *iCount )
|
LONG *iCount )
|
||||||
{
|
{
|
||||||
struct objectset *objectset = impl_from_ISWbemObjectSet( iface );
|
struct objectset *objectset = impl_from_ISWbemObjectSet( iface );
|
||||||
LONG count = 0, total = 0;
|
|
||||||
|
|
||||||
TRACE( "%p, %p\n", objectset, iCount );
|
TRACE( "%p, %p\n", objectset, iCount );
|
||||||
|
|
||||||
while (IEnumWbemClassObject_Skip( objectset->objectenum, WBEM_INFINITE, 1 ) == S_OK) count++;
|
*iCount = objectset->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;
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,6 +558,14 @@ static const ISWbemObjectSetVtbl objectset_vtbl =
|
||||||
objectset_ItemIndex
|
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 )
|
static HRESULT SWbemObjectSet_create( IEnumWbemClassObject *wbem_objectenum, ISWbemObjectSet **obj )
|
||||||
{
|
{
|
||||||
struct objectset *objectset;
|
struct objectset *objectset;
|
||||||
|
@ -578,6 +577,7 @@ static HRESULT SWbemObjectSet_create( IEnumWbemClassObject *wbem_objectenum, ISW
|
||||||
objectset->refs = 1;
|
objectset->refs = 1;
|
||||||
objectset->objectenum = wbem_objectenum;
|
objectset->objectenum = wbem_objectenum;
|
||||||
IEnumWbemClassObject_AddRef( objectset->objectenum );
|
IEnumWbemClassObject_AddRef( objectset->objectenum );
|
||||||
|
objectset->count = get_object_count( objectset->objectenum );
|
||||||
|
|
||||||
*obj = &objectset->ISWbemObjectSet_iface;
|
*obj = &objectset->ISWbemObjectSet_iface;
|
||||||
TRACE( "returning iface %p\n", *obj );
|
TRACE( "returning iface %p\n", *obj );
|
||||||
|
|
Loading…
Reference in New Issue