Commit 131d0b9f authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Optimize GetDispID usage.

parent b54f449e
......@@ -517,8 +517,6 @@ static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
{
DispatchEx *This = DISPATCHEX_THIS(iface);
dispex_prop_t *prop;
HRESULT hres;
TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
......@@ -527,16 +525,7 @@ static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DW
return E_NOTIMPL;
}
hres = find_prop_name_prot(This, bstrName, (grfdex&fdexNameEnsure) != 0, &prop);
if(FAILED(hres))
return hres;
if(prop) {
*pid = prop_to_id(This, prop);
return S_OK;
}
TRACE("not found %s\n", debugstr_w(bstrName));
return DISP_E_UNKNOWNNAME;
return jsdisp_get_id(This, bstrName, grfdex, pid);
}
static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
......@@ -800,6 +789,24 @@ DispatchEx *iface_to_jsdisp(IUnknown *iface)
return ret;
}
HRESULT jsdisp_get_id(DispatchEx *jsdisp, const WCHAR *name, DWORD flags, DISPID *id)
{
dispex_prop_t *prop;
HRESULT hres;
hres = find_prop_name_prot(jsdisp, name, (flags&fdexNameEnsure) != 0, &prop);
if(FAILED(hres))
return hres;
if(prop) {
*id = prop_to_id(jsdisp, prop);
return S_OK;
}
TRACE("not found %s\n", debugstr_w(name));
return DISP_E_UNKNOWNNAME;
}
HRESULT jsdisp_call_value(DispatchEx *disp, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv,
jsexcept_t *ei, IServiceProvider *caller)
{
......
......@@ -203,13 +203,6 @@ void exec_release(exec_ctx_t *ctx)
heap_free(ctx);
}
static HRESULT dispex_get_id(IDispatchEx *dispex, BSTR name, DWORD flags, DISPID *id)
{
*id = 0;
return IDispatchEx_GetDispID(dispex, name, flags|fdexNameCaseSensitive, id);
}
static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id)
{
IDispatchEx *dispex;
......@@ -223,7 +216,8 @@ static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id)
return IDispatch_GetIDsOfNames(disp, &IID_NULL, &name, 1, 0, id);
}
hres = dispex_get_id(dispex, name, flags, id);
*id = 0;
hres = IDispatchEx_GetDispID(dispex, name, flags|fdexNameCaseSensitive, id);
IDispatchEx_Release(dispex);
return hres;
}
......@@ -433,7 +427,7 @@ static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, ex
TRACE("%s\n", debugstr_w(identifier));
for(scope = ctx->scope_chain; scope; scope = scope->next) {
hres = dispex_get_id(_IDispatchEx_(scope->obj), identifier, 0, &id);
hres = jsdisp_get_id(scope->obj, identifier, 0, &id);
if(SUCCEEDED(hres))
break;
}
......@@ -443,7 +437,7 @@ static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, ex
return S_OK;
}
hres = dispex_get_id(_IDispatchEx_(ctx->parser->script->global), identifier, 0, &id);
hres = jsdisp_get_id(ctx->parser->script->global, identifier, 0, &id);
if(SUCCEEDED(hres)) {
exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->global), id);
return S_OK;
......@@ -460,14 +454,14 @@ static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, ex
return S_OK;
}
hres = dispex_get_id(_IDispatchEx_(ctx->parser->script->script_disp), identifier, 0, &id);
hres = jsdisp_get_id(ctx->parser->script->script_disp, identifier, 0, &id);
if(SUCCEEDED(hres)) {
exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->script_disp), id);
return S_OK;
}
if(flags & EXPR_NEWREF) {
hres = dispex_get_id(_IDispatchEx_(ctx->var_disp), identifier, fdexNameEnsure, &id);
hres = jsdisp_get_id(ctx->var_disp, identifier, fdexNameEnsure, &id);
if(FAILED(hres))
return hres;
......
......@@ -127,6 +127,7 @@ HRESULT disp_propput(IDispatch*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvide
HRESULT jsdisp_propput_name(DispatchEx*,const WCHAR*,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_propput_idx(DispatchEx*,DWORD,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_propget_idx(DispatchEx*,DWORD,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
HRESULT jsdisp_get_id(DispatchEx*,const WCHAR*,DWORD,DISPID*);
HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,DWORD,DispatchEx*,DispatchEx**);
......
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