Commit c3ae1356 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Optimize nsAString handling.

parent 22d49376
......@@ -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)) {
......
......@@ -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*);
......
......@@ -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);
......
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