markup substitutions enhancements.
Do not preemptively allocate a g_markup_escape_text for substitutions, just remember what we want to substitute markup with, and substitute it in the final buffer efficiently. Signed-off-by: Pierre Habouzit <madcoder@debian.org>
This commit is contained in:
parent
943e2035fa
commit
37d69b8dcc
4
client.c
4
client.c
|
@ -769,8 +769,7 @@ char *
|
|||
client_markup_parse(client_t *c, const char *str, ssize_t len)
|
||||
{
|
||||
const char *elements[] = { "title", NULL };
|
||||
char *title_esc = g_markup_escape_text(c->name, -1);
|
||||
const char *elements_sub[] = { title_esc , NULL };
|
||||
const char *elements_sub[] = { c->name , NULL };
|
||||
markup_parser_data_t p;
|
||||
char *ret;
|
||||
|
||||
|
@ -784,7 +783,6 @@ client_markup_parse(client_t *c, const char *str, ssize_t len)
|
|||
ret = a_strdup(str);
|
||||
|
||||
markup_parser_data_wipe(&p);
|
||||
p_delete(&title_esc);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ markup_parse_start_element(GMarkupParseContext *context __attribute__ ((unused))
|
|||
|
||||
if(p->elements_sub && p->elements_sub[i])
|
||||
{
|
||||
buffer_adds(&p->text, p->elements_sub[i]);
|
||||
buffer_add_xmlescaped(&p->text, p->elements_sub[i]);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -58,22 +58,18 @@ static char *
|
|||
tag_markup_parse(tag_t *t, const char *str, ssize_t len)
|
||||
{
|
||||
const char *elements[] = { "title", NULL };
|
||||
char *title_esc = g_markup_escape_text(t->name, -1);
|
||||
const char *elements_sub[] = { title_esc , NULL };
|
||||
const char *elements_sub[] = { t->name , NULL };
|
||||
markup_parser_data_t p;
|
||||
char *ret;
|
||||
|
||||
markup_parser_data_init(&p, elements, elements_sub, countof(elements));
|
||||
|
||||
if(markup_parse(&p, str, len))
|
||||
{
|
||||
ret = buffer_detach(&p.text);
|
||||
}
|
||||
else
|
||||
ret = a_strdup(str);
|
||||
|
||||
markup_parser_data_wipe(&p);
|
||||
p_delete(&title_esc);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue