diff options
author | Alexander Larsson <alexl@redhat.com> | 2018-09-10 05:09:12 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2018-09-10 05:09:12 +0200 |
commit | b128e52915065d8b1fef23485b0e9c27988fba1d (patch) | |
tree | 1c5331a52c659aa92606ac9418918420627a597d /gtk/gtkbuilderparser.c | |
parent | 005f932d13dafd01c9fcf7565be1a4fb9280228c (diff) | |
download | gtk+-wip/alexl/gtkbuilder-xml-preparse.tar.gz |
Use pre-parsed xml for GtkBuilder resource fileswip/alexl/gtkbuilder-xml-preparse
This enables the xml-preparser gresource option which
runs the xml through g_markup_parser_context_record(), and saves
the generated binary format instead of the xml. We then check
for the magic marker in the GtkBuilder code so that this automatically
uses g_markup_parser_context_replay() instead, to avoid any
parsing. The binary format is also smaller.
Diffstat (limited to 'gtk/gtkbuilderparser.c')
-rw-r--r-- | gtk/gtkbuilderparser.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c index 94c5b8b6c1..dac4a75984 100644 --- a/gtk/gtkbuilderparser.c +++ b/gtk/gtkbuilderparser.c @@ -1269,8 +1269,19 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder, G_MARKUP_TREAT_CDATA_AS_TEXT, &data, NULL); - if (!g_markup_parse_context_parse (data.ctx, buffer, length, error)) - goto out; + if (buffer[0] == 'G' && + buffer[1] == 'M' && + buffer[2] == 'U' && + buffer[3] == 0) + { + if (!g_markup_parse_context_replay (data.ctx, buffer, length, error)) + goto out; + } + else + { + if (!g_markup_parse_context_parse (data.ctx, buffer, length, error)) + goto out; + } _gtk_builder_finish (builder); if (_gtk_builder_lookup_failed (builder, error)) |