[maemo-commits] [maemo-commits] r17606 - in projects/haf/trunk/gconf2: . backends
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Mon Mar 9 12:29:45 EET 2009
- Previous message: [maemo-commits] r17605 - in projects/haf/trunk/libhildonmime: . debian docs libhildonmime tests/datadir/applications/test
- Next message: [maemo-commits] r17607 - in projects/haf/trunk/gconf2: . backends
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: richard Date: 2009-03-09 12:29:34 +0200 (Mon, 09 Mar 2009) New Revision: 17606 Modified: projects/haf/trunk/gconf2/ChangeLog projects/haf/trunk/gconf2/backends/markup-tree.c Log: Merge revision 2763 from upstream, to optimize the markup backend. Modified: projects/haf/trunk/gconf2/ChangeLog =================================================================== --- projects/haf/trunk/gconf2/ChangeLog 2009-03-09 10:16:25 UTC (rev 17605) +++ projects/haf/trunk/gconf2/ChangeLog 2009-03-09 10:29:34 UTC (rev 17606) @@ -1,3 +1,8 @@ +2009-03-09 Richard Hult <richard at imendio.com> + + * Merge revision 2763 from upstream, to optimize the markup + backend. + 2009-02-06 Richard Hult <richard at imendio.com> * backends/markup-tree.c (save_tree_with_locale): Also fflush() Modified: projects/haf/trunk/gconf2/backends/markup-tree.c =================================================================== --- projects/haf/trunk/gconf2/backends/markup-tree.c 2009-03-09 10:16:25 UTC (rev 17605) +++ projects/haf/trunk/gconf2/backends/markup-tree.c 2009-03-09 10:29:34 UTC (rev 17606) @@ -3659,7 +3659,7 @@ * Save */ -#define INDENT_SPACES 8 +#define INDENT_SPACES 1 static gboolean write_list_children (GConfValue *value, FILE *f, @@ -3673,6 +3673,17 @@ GSList *local_schemas, gboolean save_as_subtree); +/* the common case - before we start interning */ +static const char write_indents_static[] = + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" /* 16 */ + "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; /* 32 */ + +static const char *make_whitespace (int indent) +{ + int idx = MAX (sizeof (write_indents_static) - 1 - indent, 0); + return &write_indents_static[idx]; +} + static gboolean write_value_element (GConfValue *value, const char *closing_element, @@ -3681,8 +3692,7 @@ GSList *local_schemas, gboolean save_as_subtree) { - char *whitespace; - + gboolean single_element = FALSE; /* We are at the "<foo bar="whatever"" stage here, * <foo> still missing the closing > */ @@ -3810,17 +3820,13 @@ s = g_markup_escape_text (gconf_value_get_string (value), -1); - whitespace = g_strnfill (indent + INDENT_SPACES, ' '); - if (fprintf (f, "%s<stringvalue>%s</stringvalue>\n", - whitespace, s) < 0) + make_whitespace (indent + INDENT_SPACES), s) < 0) { - g_free (whitespace); g_free (s); return FALSE; } - g_free (whitespace); g_free (s); } break; @@ -3851,13 +3857,8 @@ break; } - whitespace = g_strnfill (indent, ' '); - if (fprintf (f, "%s</%s>\n", whitespace, closing_element) < 0) - { - g_free (whitespace); + if (fprintf (f, "%s</%s>\n", make_whitespace (indent), closing_element) < 0) return FALSE; - } - g_free (whitespace); return TRUE; } @@ -3869,16 +3870,13 @@ { GSList *tmp; gboolean retval = FALSE; - char *whitespace; - whitespace = g_strnfill (indent, ' '); - tmp = gconf_value_get_list (value); while (tmp != NULL) { GConfValue *li = tmp->data; - if (fputs (whitespace, f) < 0) + if (fputs (make_whitespace (indent), f) < 0) goto out; if (fputs ("<li", f) < 0) @@ -3894,8 +3892,6 @@ out: - g_free (whitespace); - return retval; } @@ -3906,15 +3902,12 @@ { GConfValue *child; gboolean retval = FALSE; - char *whitespace; - whitespace = g_strnfill (indent, ' '); - child = gconf_value_get_car (value); if (child != NULL) { - if (fputs (whitespace, f) < 0) + if (fputs (make_whitespace (indent), f) < 0) goto out; if (fputs ("<car", f) < 0) @@ -3928,7 +3921,7 @@ if (child != NULL) { - if (fputs (whitespace, f) < 0) + if (fputs (make_whitespace (indent), f) < 0) goto out; if (fputs ("<cdr", f) < 0) @@ -3942,8 +3935,6 @@ out: - g_free (whitespace); - return retval; } @@ -3955,7 +3946,7 @@ gboolean write_descs) { gboolean retval; - char *whitespace1, *whitespace2; + const char *whitespace1, *whitespace2; char *s; if (!write_descs && local_schema->default_value == NULL) @@ -3963,8 +3954,8 @@ retval = FALSE; - whitespace1 = g_strnfill (indent, ' '); - whitespace2 = g_strnfill (indent + INDENT_SPACES, ' '); + whitespace1 = make_whitespace (indent); + whitespace2 = make_whitespace (indent + INDENT_SPACES); if (fputs (whitespace1, f) < 0) goto out; @@ -4049,9 +4040,6 @@ out: - g_free (whitespace1); - g_free (whitespace2); - return retval; } @@ -4149,7 +4137,6 @@ { LocalSchemaInfo *local_schema_info; gboolean retval; - char *whitespace; retval = FALSE; local_schema_info = NULL; @@ -4168,11 +4155,9 @@ } } - whitespace = g_strnfill (indent, ' '); - g_assert (entry->name != NULL); - if (fprintf (f, "%s<entry name=\"%s\"", whitespace, entry->name) < 0) + if (fprintf (f, "%s<entry name=\"%s\"", make_whitespace (indent), entry->name) < 0) goto out; if (local_schema_info == NULL) @@ -4220,7 +4205,7 @@ TRUE)) goto out; - if (fprintf (f, "%s</entry>\n", whitespace) < 0) + if (fprintf (f, "%s</entry>\n", make_whitespace (indent)) < 0) goto out; } @@ -4228,8 +4213,6 @@ out: - g_free (whitespace); - return retval; } @@ -4243,18 +4226,16 @@ { GSList *tmp; gboolean retval = FALSE; - char *whitespace; dir->not_in_filesystem = TRUE; if (save_as_subtree && locale != NULL && dir->is_dir_empty) return TRUE; - whitespace = g_strnfill (indent, ' '); - g_assert (dir->name != NULL); - if (fprintf (f, "%s<dir name=\"%s\">\n", whitespace, dir->name) < 0) + if (fprintf (f, "%s<dir name=\"%s\">\n", + make_whitespace (indent), dir->name) < 0) goto out; tmp = dir->entries; @@ -4289,15 +4270,13 @@ tmp = tmp->next; } - if (fprintf (f, "%s</dir>\n", whitespace) < 0) + if (fprintf (f, "%s</dir>\n", make_whitespace (indent)) < 0) return FALSE; retval = TRUE; out: - g_free (whitespace); - return retval; }
- Previous message: [maemo-commits] r17605 - in projects/haf/trunk/libhildonmime: . debian docs libhildonmime tests/datadir/applications/test
- Next message: [maemo-commits] r17607 - in projects/haf/trunk/gconf2: . backends
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]