Commit c4d88c74 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Small optimizations

parent f4f64800
2006-05-28 Matthias Clasen <mclasen@redhat.com>
* glib/gmarkup.c (g_markup_parse_context_parse):
Don't use g_str_has_{prefix,suffix} here.
2006-05-28 Matthias Clasen <mclasen@redhat.com>
* glib/gmarkup.h: Add a GMarkupParseFlags flag for
......
2006-05-28 Matthias Clasen <mclasen@redhat.com>
* glib/gmarkup.c (g_markup_parse_context_parse):
Don't use g_str_has_{prefix,suffix} here.
2006-05-28 Matthias Clasen <mclasen@redhat.com>
* glib/gmarkup.h: Add a GMarkupParseFlags flag for
......
......@@ -1624,18 +1624,27 @@ g_markup_parse_context_parse (GMarkupParseContext *context,
if (*context->iter == '<')
context->balance++;
if (*context->iter == '>')
{
{
gchar *str;
gsize len;
context->balance--;
add_to_partial (context, context->start, context->iter);
context->start = context->iter;
if ((g_str_has_prefix (context->partial_chunk->str, "<?")
&& g_str_has_suffix (context->partial_chunk->str, "?")) ||
(g_str_has_prefix (context->partial_chunk->str, "<!--")
&& g_str_has_suffix (context->partial_chunk->str, "--")) ||
(g_str_has_prefix (context->partial_chunk->str, "<![CDATA[")
&& g_str_has_suffix (context->partial_chunk->str, "]]")) ||
(g_str_has_prefix (context->partial_chunk->str, "<!DOCTYPE")
&& context->balance == 0))
str = context->partial_chunk->str;
len = context->partial_chunk->len;
if (str[1] == '?' && str[len - 1] == '?')
break;
if (strncmp (str, "<!--", 4) == 0 &&
strcmp (str + len - 2, "--") == 0)
break;
if (strncmp (str, "<![CDATA[", 9) == 0 &&
strcmp (str + len - 2, "]]") == 0)
break;
if (strncmp (str, "<!DOCTYPE", 9) == 0 &&
context->balance == 0)
break;
}
}
......@@ -1661,13 +1670,12 @@ g_markup_parse_context_parse (GMarkupParseContext *context,
add_to_partial (context, context->start, context->iter);
if (context->flags & G_MARKUP_TREAT_CDATA_AS_TEXT &&
g_str_has_prefix (context->partial_chunk->str, "<![CDATA[") &&
g_str_has_suffix (context->partial_chunk->str, "]]>"))
strncmp (context->partial_chunk->str, "<![CDATA[", 9) == 0)
{
if (context->parser->text)
(*context->parser->text) (context,
context->partial_chunk->str + strlen ("<![CDATA["),
context->partial_chunk->len - strlen ("<![CDATA[" "]]>"),
context->partial_chunk->str + 9,
context->partial_chunk->len - 12,
context->user_data,
&tmp_error);
}
......
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