Module: wine Branch: master Commit: c3ae1356d6d283b870c09a83572dd72095af4dfc URL: http://source.winehq.org/git/wine.git/?a=commit;h=c3ae1356d6d283b870c09a8357...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Jan 28 23:55:06 2010 +0100
mshtml: Optimize nsAString handling.
---
dlls/mshtml/htmlstyle.c | 10 +++++----- dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/nsembed.c | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index 467464a..04ba1d6 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -315,9 +315,9 @@ HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LPCW if(flags & ATTR_FIX_URL) val = fix_url_value(value);
- nsAString_Init(&str_name, style_tbl[sid].name); - nsAString_Init(&str_value, val ? val : value); - nsAString_Init(&str_empty, wszEmpty); + nsAString_InitDepend(&str_name, style_tbl[sid].name); + nsAString_InitDepend(&str_value, val ? val : value); + nsAString_InitDepend(&str_empty, wszEmpty); heap_free(val);
nsres = nsIDOMCSSStyleDeclaration_SetProperty(nsstyle, &str_name, &str_value, &str_empty); @@ -369,7 +369,7 @@ static HRESULT get_nsstyle_attr_nsval(nsIDOMCSSStyleDeclaration *nsstyle, stylei nsAString str_name; nsresult nsres;
- nsAString_Init(&str_name, style_tbl[sid].name); + nsAString_InitDepend(&str_name, style_tbl[sid].name);
nsres = nsIDOMCSSStyleDeclaration_GetPropertyValue(nsstyle, &str_name, value); if(NS_FAILED(nsres)) { @@ -2129,7 +2129,7 @@ static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v)
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
- nsAString_Init(&text_str, v); + nsAString_InitDepend(&text_str, v); nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str); nsAString_Finish(&text_str); if(NS_FAILED(nsres)) { diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index a8cd32f..2fafdf0 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -712,6 +712,7 @@ void nsACString_SetData(nsACString*,const char*); PRUint32 nsACString_GetData(const nsACString*,const char**);
BOOL nsAString_Init(nsAString*,const PRUnichar*); +void nsAString_InitDepend(nsAString*,const PRUnichar*); void nsAString_SetData(nsAString*,const PRUnichar*); PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**); void nsAString_Finish(nsAString*); diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c index 0e0d4b5..0e7ea89 100644 --- a/dlls/mshtml/nsembed.c +++ b/dlls/mshtml/nsembed.c @@ -55,6 +55,8 @@ struct nsCStringContainer { PRUint32 d3; };
+#define NS_STRING_CONTAINER_INIT_DEPEND 0x0002 + static nsresult (*NS_InitXPCOM2)(nsIServiceManager**,void*,void*); static nsresult (*NS_ShutdownXPCOM)(nsIServiceManager*); static nsresult (*NS_GetComponentRegistrar)(nsIComponentRegistrar**); @@ -560,6 +562,15 @@ BOOL nsAString_Init(nsAString *str, const PRUnichar *data) return NS_SUCCEEDED(NS_StringContainerInit2(str, data, PR_UINT32_MAX, 0)); }
+/* + * Initializes nsAString with data owned by caller. + * Caller must ensure that data is valid during lifetime of string object. + */ +void nsAString_InitDepend(nsAString *str, const PRUnichar *data) +{ + NS_StringContainerInit2(str, data, PR_UINT32_MAX, NS_STRING_CONTAINER_INIT_DEPEND); +} + void nsAString_SetData(nsAString *str, const PRUnichar *data) { NS_StringSetData(str, data, PR_UINT32_MAX);