Skip to content

Commit 1d2c544

Browse files
authored
Refactor disp_invokeex() to avoid superfluous recheck (GH-17001)
Since we already know the method is callable, we can just call it directly.
1 parent 514cd20 commit 1d2c544

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

ext/com_dotnet/com_wrapper.c

+14-19
Original file line numberDiff line numberDiff line change
@@ -256,31 +256,26 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
256256

257257
/* TODO: if PHP raises an exception here, we should catch it
258258
* and expose it as a COM exception */
259-
259+
zend_fcall_info_cache fcc;
260260
if (wFlags & DISPATCH_PROPERTYPUT) {
261261
zend_update_property(Z_OBJCE(disp->object), Z_OBJ(disp->object), Z_STRVAL_P(name), Z_STRLEN_P(name), &params[0]);
262262
ret = S_OK;
263-
} else if (wFlags & DISPATCH_METHOD && zend_is_callable_ex(name, Z_OBJ(disp->object), 0, NULL, NULL, NULL)) {
263+
} else if (wFlags & DISPATCH_METHOD && zend_is_callable_ex(name, Z_OBJ(disp->object), 0, NULL, &fcc, NULL)) {
264264
zend_try {
265265
retval = &rv;
266-
if (SUCCESS == call_user_function(NULL, &disp->object, name,
267-
retval, pdp->cArgs, params)) {
268-
ret = S_OK;
269-
trace("function called ok\n");
270-
271-
/* Copy any modified values to callers copy of variant*/
272-
for (i = 0; i < pdp->cArgs; i++) {
273-
php_com_dotnet_object *obj = CDNO_FETCH(&params[i]);
274-
VARIANT *srcvar = &obj->v;
275-
VARIANT *dstvar = &pdp->rgvarg[ pdp->cArgs - 1 - i];
276-
if ((V_VT(dstvar) & VT_BYREF) && obj->modified ) {
277-
trace("percolate modified value for arg %u VT=%08x\n", i, V_VT(dstvar));
278-
php_com_copy_variant(dstvar, srcvar);
279-
}
266+
zend_call_known_fcc(&fcc, retval, pdp->cArgs, params, NULL);
267+
ret = S_OK;
268+
trace("function called ok\n");
269+
270+
/* Copy any modified values to callers copy of variant*/
271+
for (i = 0; i < pdp->cArgs; i++) {
272+
php_com_dotnet_object *obj = CDNO_FETCH(&params[i]);
273+
VARIANT *srcvar = &obj->v;
274+
VARIANT *dstvar = &pdp->rgvarg[ pdp->cArgs - 1 - i];
275+
if ((V_VT(dstvar) & VT_BYREF) && obj->modified ) {
276+
trace("percolate modified value for arg %u VT=%08x\n", i, V_VT(dstvar));
277+
php_com_copy_variant(dstvar, srcvar);
280278
}
281-
} else {
282-
trace("failed to call func\n");
283-
ret = DISP_E_EXCEPTION;
284279
}
285280
} zend_catch {
286281
trace("something blew up\n");

0 commit comments

Comments
 (0)