[glib/new-gsettings] move byteswapping from reader to gsettingsschema



commit 71c30304ead921ea5056bb75f77349fb9bd6f22d
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Apr 15 16:36:18 2010 -0400

    move byteswapping from reader to gsettingsschema

 gio/gsettingsschema.c  |   20 +++++++++++++++++++-
 gio/gvdb/gvdb-reader.c |   15 +--------------
 2 files changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c
index 9f21089..7ed0acf 100644
--- a/gio/gsettingsschema.c
+++ b/gio/gsettingsschema.c
@@ -118,7 +118,7 @@ g_settings_schema_get_string (GSettingsSchema *schema,
   const gchar *result = NULL;
   GVariant *value;
 
-  if ((value = g_settings_schema_get_value (schema, key, NULL)))
+  if ((value = gvdb_table_get_value (schema->priv->table, key, NULL)))
     {
       result = g_variant_get_string (value, NULL);
       g_variant_unref (value);
@@ -166,7 +166,25 @@ g_settings_schema_get_value (GSettingsSchema  *schema,
                              const gchar      *key,
                              GVariant        **options)
 {
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+  GVariant *variant, *tmp;
+
+  tmp = gvdb_table_get_value (schema->priv->table, key, options);
+
+  if (tmp)
+    {
+      variant = g_variant_byteswap (tmp);
+      g_variant_unref (tmp);
+    }
+  else
+    variant = NULL;
+
+  /* NOTE: no options have byteswapped data in them at the moment */
+
+  return variant;
+#else
   return gvdb_table_get_value (schema->priv->table, key, options);
+#endif
 }
 
 const gchar *
diff --git a/gio/gvdb/gvdb-reader.c b/gio/gvdb/gvdb-reader.c
index 9a7a8d5..65bef5e 100644
--- a/gio/gvdb/gvdb-reader.c
+++ b/gio/gvdb/gvdb-reader.c
@@ -413,13 +413,6 @@ gvdb_table_get_value (GvdbTable    *file,
   value = g_variant_get_variant (variant);
   g_variant_unref (variant);
 
-  if (file->byteswapped)
-    {
-      GVariant *tmp = g_variant_byteswap (value);
-      g_variant_unref (value);
-      value = tmp;
-    }
-
   if (options != NULL)
     {
       data = gvdb_table_dereference (file, &item->options, 8, &size);
@@ -431,13 +424,6 @@ gvdb_table_get_value (GvdbTable    *file,
                                               (GDestroyNotify) g_mapped_file_unref,
                                               g_mapped_file_ref (file->mapped));
           g_variant_ref_sink (*options);
-
-          if (file->byteswapped)
-            {
-              GVariant *tmp = g_variant_byteswap (*options);
-              g_variant_unref (*options);
-              *options = tmp;
-            }
         }
       else
         *options = NULL;
@@ -479,6 +465,7 @@ gvdb_table_get_table (GvdbTable   *file,
 
   new = g_slice_new0 (GvdbTable);
   new->mapped = g_mapped_file_ref (file->mapped);
+  new->byteswapped = file->byteswapped;
   new->trusted = file->trusted;
   new->data = file->data;
   new->size = file->size;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]