mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-27 00:40:15 +03:00
Use interns for string comparisons.
This commit is contained in:
parent
483d32cadc
commit
81e079e747
@ -766,7 +766,7 @@ static bool html_meta_refresh_process_element(html_content *c, dom_node *n)
|
||||
if (equiv == NULL)
|
||||
return true;
|
||||
|
||||
if (strcasecmp(dom_string_data(equiv), "refresh") != 0) {
|
||||
if (!dom_string_caseless_lwc_isequal(equiv, corestring_lwc_refresh)) {
|
||||
dom_string_unref(equiv);
|
||||
return true;
|
||||
}
|
||||
@ -982,8 +982,8 @@ static bool html_meta_refresh(html_content *c, dom_node *head)
|
||||
}
|
||||
|
||||
/* Recurse into noscript elements */
|
||||
if (strcasecmp(dom_string_data(name),
|
||||
"noscript") == 0) {
|
||||
if (dom_string_caseless_lwc_isequal(name,
|
||||
corestring_lwc_noscript)) {
|
||||
if (html_meta_refresh(c, n) == false) {
|
||||
/* Some error occurred */
|
||||
dom_string_unref(name);
|
||||
@ -995,8 +995,8 @@ static bool html_meta_refresh(html_content *c, dom_node *head)
|
||||
dom_node_unref(n);
|
||||
return true;
|
||||
}
|
||||
} else if (strcasecmp(dom_string_data(name),
|
||||
"meta") == 0) {
|
||||
} else if (dom_string_caseless_lwc_isequal(name,
|
||||
corestring_lwc_meta)) {
|
||||
if (html_meta_refresh_process_element(c,
|
||||
n) == false) {
|
||||
/* Some error occurred */
|
||||
@ -1428,7 +1428,8 @@ html_process_style_element(html_content *c,
|
||||
/* type='text/css', or not present (invalid but common) */
|
||||
exc = dom_element_get_attribute(style, corestring_dom_type, &val);
|
||||
if (exc == DOM_NO_ERR && val != NULL) {
|
||||
if (strcasecmp(dom_string_data(val), "text/css") != 0) {
|
||||
if (!dom_string_caseless_lwc_isequal(val,
|
||||
corestring_lwc_text_css)) {
|
||||
dom_string_unref(val);
|
||||
return true;
|
||||
}
|
||||
@ -1675,14 +1676,14 @@ html_process_stylesheet(dom_node *node, dom_string *name, void *vctx)
|
||||
hlcache_child_context child;
|
||||
|
||||
/* deal with style nodes */
|
||||
if (strcasecmp(dom_string_data(name), "style") == 0) {
|
||||
if (dom_string_caseless_lwc_isequal(name, corestring_lwc_style)) {
|
||||
if (!html_process_style_element(ctx->c, &ctx->count, node))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* if it is not a link node skip it */
|
||||
if (strcasecmp(dom_string_data(name), "link") != 0) {
|
||||
if (!dom_string_caseless_lwc_isequal(name, corestring_lwc_link)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1705,7 +1706,8 @@ html_process_stylesheet(dom_node *node, dom_string *name, void *vctx)
|
||||
/* type='text/css' or not present */
|
||||
exc = dom_element_get_attribute(node, corestring_dom_type, &type_attr);
|
||||
if (exc == DOM_NO_ERR && type_attr != NULL) {
|
||||
if (strcasecmp(dom_string_data(type_attr), "text/css") != 0) {
|
||||
if (!dom_string_caseless_lwc_isequal(type_attr,
|
||||
corestring_lwc_text_css)) {
|
||||
dom_string_unref(type_attr);
|
||||
return true;
|
||||
}
|
||||
|
@ -63,8 +63,10 @@ lwc_string *corestring_lwc_input;
|
||||
lwc_string *corestring_lwc_justify;
|
||||
lwc_string *corestring_lwc_left;
|
||||
lwc_string *corestring_lwc_link;
|
||||
lwc_string *corestring_lwc_meta;
|
||||
lwc_string *corestring_lwc_middle;
|
||||
lwc_string *corestring_lwc_multipart_form_data;
|
||||
lwc_string *corestring_lwc_noscript;
|
||||
lwc_string *corestring_lwc_object;
|
||||
lwc_string *corestring_lwc_p;
|
||||
lwc_string *corestring_lwc_password;
|
||||
@ -74,8 +76,10 @@ lwc_string *corestring_lwc_post;
|
||||
lwc_string *corestring_lwc_radio;
|
||||
lwc_string *corestring_lwc_rect;
|
||||
lwc_string *corestring_lwc_rectangle;
|
||||
lwc_string *corestring_lwc_refresh;
|
||||
lwc_string *corestring_lwc_reset;
|
||||
lwc_string *corestring_lwc_right;
|
||||
lwc_string *corestring_lwc_style;
|
||||
lwc_string *corestring_lwc_submit;
|
||||
lwc_string *corestring_lwc_table;
|
||||
lwc_string *corestring_lwc_tbody;
|
||||
@ -83,12 +87,14 @@ lwc_string *corestring_lwc_td;
|
||||
lwc_string *corestring_lwc_text;
|
||||
lwc_string *corestring_lwc_textarea;
|
||||
lwc_string *corestring_lwc_texttop;
|
||||
lwc_string *corestring_lwc_text_css;
|
||||
lwc_string *corestring_lwc_tfoot;
|
||||
lwc_string *corestring_lwc_th;
|
||||
lwc_string *corestring_lwc_thead;
|
||||
lwc_string *corestring_lwc_title;
|
||||
lwc_string *corestring_lwc_top;
|
||||
lwc_string *corestring_lwc_tr;
|
||||
lwc_string *corestring_lwc_url;
|
||||
lwc_string *corestring_lwc__blank;
|
||||
lwc_string *corestring_lwc__parent;
|
||||
lwc_string *corestring_lwc__self;
|
||||
@ -186,8 +192,10 @@ void corestrings_fini(void)
|
||||
CSS_LWC_STRING_UNREF(justify);
|
||||
CSS_LWC_STRING_UNREF(left);
|
||||
CSS_LWC_STRING_UNREF(link);
|
||||
CSS_LWC_STRING_UNREF(meta);
|
||||
CSS_LWC_STRING_UNREF(middle);
|
||||
CSS_LWC_STRING_UNREF(multipart_form_data);
|
||||
CSS_LWC_STRING_UNREF(noscript);
|
||||
CSS_LWC_STRING_UNREF(object);
|
||||
CSS_LWC_STRING_UNREF(p);
|
||||
CSS_LWC_STRING_UNREF(password);
|
||||
@ -197,8 +205,10 @@ void corestrings_fini(void)
|
||||
CSS_LWC_STRING_UNREF(radio);
|
||||
CSS_LWC_STRING_UNREF(rect);
|
||||
CSS_LWC_STRING_UNREF(rectangle);
|
||||
CSS_LWC_STRING_UNREF(refresh);
|
||||
CSS_LWC_STRING_UNREF(reset);
|
||||
CSS_LWC_STRING_UNREF(right);
|
||||
CSS_LWC_STRING_UNREF(style);
|
||||
CSS_LWC_STRING_UNREF(submit);
|
||||
CSS_LWC_STRING_UNREF(table);
|
||||
CSS_LWC_STRING_UNREF(tbody);
|
||||
@ -206,12 +216,14 @@ void corestrings_fini(void)
|
||||
CSS_LWC_STRING_UNREF(text);
|
||||
CSS_LWC_STRING_UNREF(textarea);
|
||||
CSS_LWC_STRING_UNREF(texttop);
|
||||
CSS_LWC_STRING_UNREF(text_css);
|
||||
CSS_LWC_STRING_UNREF(tfoot);
|
||||
CSS_LWC_STRING_UNREF(th);
|
||||
CSS_LWC_STRING_UNREF(thead);
|
||||
CSS_LWC_STRING_UNREF(title);
|
||||
CSS_LWC_STRING_UNREF(top);
|
||||
CSS_LWC_STRING_UNREF(tr);
|
||||
CSS_LWC_STRING_UNREF(url);
|
||||
CSS_LWC_STRING_UNREF(_blank);
|
||||
CSS_LWC_STRING_UNREF(_parent);
|
||||
CSS_LWC_STRING_UNREF(_self);
|
||||
@ -329,7 +341,9 @@ nserror corestrings_init(void)
|
||||
CSS_LWC_STRING_INTERN(justify);
|
||||
CSS_LWC_STRING_INTERN(left);
|
||||
CSS_LWC_STRING_INTERN(link);
|
||||
CSS_LWC_STRING_INTERN(meta);
|
||||
CSS_LWC_STRING_INTERN(middle);
|
||||
CSS_LWC_STRING_INTERN(noscript);
|
||||
CSS_LWC_STRING_INTERN(object);
|
||||
CSS_LWC_STRING_INTERN(p);
|
||||
CSS_LWC_STRING_INTERN(password);
|
||||
@ -339,8 +353,10 @@ nserror corestrings_init(void)
|
||||
CSS_LWC_STRING_INTERN(radio);
|
||||
CSS_LWC_STRING_INTERN(rect);
|
||||
CSS_LWC_STRING_INTERN(rectangle);
|
||||
CSS_LWC_STRING_INTERN(refresh);
|
||||
CSS_LWC_STRING_INTERN(reset);
|
||||
CSS_LWC_STRING_INTERN(right);
|
||||
CSS_LWC_STRING_INTERN(style);
|
||||
CSS_LWC_STRING_INTERN(submit);
|
||||
CSS_LWC_STRING_INTERN(table);
|
||||
CSS_LWC_STRING_INTERN(tbody);
|
||||
@ -354,6 +370,7 @@ nserror corestrings_init(void)
|
||||
CSS_LWC_STRING_INTERN(title);
|
||||
CSS_LWC_STRING_INTERN(top);
|
||||
CSS_LWC_STRING_INTERN(tr);
|
||||
CSS_LWC_STRING_INTERN(url);
|
||||
CSS_LWC_STRING_INTERN(_blank);
|
||||
CSS_LWC_STRING_INTERN(_parent);
|
||||
CSS_LWC_STRING_INTERN(_self);
|
||||
@ -367,6 +384,11 @@ nserror corestrings_init(void)
|
||||
(corestring_lwc_multipart_form_data == NULL))
|
||||
goto error;
|
||||
|
||||
lerror = lwc_intern_string("text/css", SLEN("text/css"),
|
||||
&corestring_lwc_text_css);
|
||||
if ((lerror != lwc_error_ok) || (corestring_lwc_text_css == NULL))
|
||||
goto error;
|
||||
|
||||
|
||||
#define CSS_DOM_STRING_INTERN(NAME) \
|
||||
do { \
|
||||
|
@ -67,8 +67,10 @@ extern lwc_string *corestring_lwc_input;
|
||||
extern lwc_string *corestring_lwc_justify;
|
||||
extern lwc_string *corestring_lwc_left;
|
||||
extern lwc_string *corestring_lwc_link;
|
||||
extern lwc_string *corestring_lwc_meta;
|
||||
extern lwc_string *corestring_lwc_middle;
|
||||
extern lwc_string *corestring_lwc_multipart_form_data;
|
||||
extern lwc_string *corestring_lwc_noscript;
|
||||
extern lwc_string *corestring_lwc_object;
|
||||
extern lwc_string *corestring_lwc_p;
|
||||
extern lwc_string *corestring_lwc_password;
|
||||
@ -78,8 +80,10 @@ extern lwc_string *corestring_lwc_post;
|
||||
extern lwc_string *corestring_lwc_radio;
|
||||
extern lwc_string *corestring_lwc_rect;
|
||||
extern lwc_string *corestring_lwc_rectangle;
|
||||
extern lwc_string *corestring_lwc_refresh;
|
||||
extern lwc_string *corestring_lwc_reset;
|
||||
extern lwc_string *corestring_lwc_right;
|
||||
extern lwc_string *corestring_lwc_style;
|
||||
extern lwc_string *corestring_lwc_submit;
|
||||
extern lwc_string *corestring_lwc_table;
|
||||
extern lwc_string *corestring_lwc_tbody;
|
||||
@ -87,12 +91,14 @@ extern lwc_string *corestring_lwc_td;
|
||||
extern lwc_string *corestring_lwc_text;
|
||||
extern lwc_string *corestring_lwc_textarea;
|
||||
extern lwc_string *corestring_lwc_texttop;
|
||||
extern lwc_string *corestring_lwc_text_css;
|
||||
extern lwc_string *corestring_lwc_tfoot;
|
||||
extern lwc_string *corestring_lwc_th;
|
||||
extern lwc_string *corestring_lwc_thead;
|
||||
extern lwc_string *corestring_lwc_title;
|
||||
extern lwc_string *corestring_lwc_top;
|
||||
extern lwc_string *corestring_lwc_tr;
|
||||
extern lwc_string *corestring_lwc_url;
|
||||
extern lwc_string *corestring_lwc__blank;
|
||||
extern lwc_string *corestring_lwc__parent;
|
||||
extern lwc_string *corestring_lwc__self;
|
||||
|
Loading…
Reference in New Issue
Block a user