Jacek Caban : jscript: Optimize GetDispID usage.
Alexandre Julliard
julliard at winehq.org
Wed Oct 1 14:09:29 CDT 2008
Module: wine
Branch: master
Commit: 131d0b9f1be05b51a9d54bd2fcc6999facf559ce
URL: http://source.winehq.org/git/wine.git/?a=commit;h=131d0b9f1be05b51a9d54bd2fcc6999facf559ce
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Sep 30 17:47:24 2008 +0200
jscript: Optimize GetDispID usage.
---
dlls/jscript/dispex.c | 31 +++++++++++++++++++------------
dlls/jscript/engine.c | 18 ++++++------------
dlls/jscript/jscript.h | 1 +
3 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index 896af91..81fec89 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -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)
{
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index a3e0fc1..5d231f2 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -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;
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index e4b0d1c..15e4b35 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -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**);
More information about the wine-cvs
mailing list