move byteswapping from reader to gsettingsschema

This commit is contained in:
Ryan Lortie 2010-04-15 16:36:18 -04:00
parent d0b4953423
commit 71c30304ea
2 changed files with 20 additions and 15 deletions

View File

@ -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 *

View File

@ -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;