[libdazzle] util: move gvariant hashing into util and make public



commit 451e4ee0302b000f1809f055c3bb16f1649b9cc1
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 5 01:46:17 2017 -0700

    util: move gvariant hashing into util and make public
    
    This can be useful for things when you want to hash a gvariant with a
    fallback for various container types simply doing block hashing.

 src/dazzle.h                                       |    1 +
 src/fuzzy/dzl-fuzzy-index-builder.c                |    4 ++--
 src/meson.build                                    |    4 ++--
 src/{fuzzy/dzl-fuzzy-util.c => util/dzl-variant.c} |   10 +++++-----
 src/{fuzzy/dzl-fuzzy-util.h => util/dzl-variant.h} |   12 ++++++------
 5 files changed, 16 insertions(+), 15 deletions(-)
---
diff --git a/src/dazzle.h b/src/dazzle.h
index 688de66..1da2e44 100644
--- a/src/dazzle.h
+++ b/src/dazzle.h
@@ -112,6 +112,7 @@ G_BEGIN_DECLS
 #include "util/dzl-pango.h"
 #include "util/dzl-rgba.h"
 #include "util/dzl-ring.h"
+#include "util/dzl-variant.h"
 #include "widgets/dzl-bin.h"
 #include "widgets/dzl-bolding-label.h"
 #include "widgets/dzl-box.h"
diff --git a/src/fuzzy/dzl-fuzzy-index-builder.c b/src/fuzzy/dzl-fuzzy-index-builder.c
index 90342a2..1a654c2 100644
--- a/src/fuzzy/dzl-fuzzy-index-builder.c
+++ b/src/fuzzy/dzl-fuzzy-index-builder.c
@@ -23,7 +23,7 @@
 #include <string.h>
 
 #include "fuzzy/dzl-fuzzy-index-builder.h"
-#include "fuzzy/dzl-fuzzy-util.h"
+#include "util/dzl-variant.h"
 
 struct _DzlFuzzyIndexBuilder
 {
@@ -204,7 +204,7 @@ static void
 dzl_fuzzy_index_builder_init (DzlFuzzyIndexBuilder *self)
 {
   self->documents = g_ptr_array_new_with_free_func ((GDestroyNotify)g_variant_unref);
-  self->documents_hash = g_hash_table_new (fuzzy_g_variant_hash, g_variant_equal);
+  self->documents_hash = g_hash_table_new (dzl_g_variant_hash, g_variant_equal);
   self->kv_pairs = g_array_new (FALSE, FALSE, sizeof (KVPair));
   self->strings = g_string_chunk_new (4096);
   self->key_ids = g_hash_table_new (NULL, NULL);
diff --git a/src/meson.build b/src/meson.build
index 9f7f29b..13d5d70 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -125,6 +125,7 @@ libdazzle_public_headers = [
   'util/dzl-pango.h',
   'util/dzl-rgba.h',
   'util/dzl-ring.h',
+  'util/dzl-variant.h',
 
   'widgets/dzl-bin.h',
   'widgets/dzl-bolding-label.h',
@@ -247,6 +248,7 @@ libdazzle_public_sources = [
   'util/dzl-rgba.c',
   'util/dzl-ring.c',
   'util/dzl-util.c',
+  'util/dzl-variant.c',
 
   'theming/dzl-css-provider.c',
   'theming/dzl-theme-manager.c',
@@ -286,8 +288,6 @@ libdazzle_sources = [
   'animation/dzl-frame-source.h',
 
   'fuzzy/dzl-fuzzy-index-private.h',
-  'fuzzy/dzl-fuzzy-util.c',
-  'fuzzy/dzl-fuzzy-util.h',
 
   'graphing/dzl-column-private.h',
   'graphing/dzl-graph-column-private.h',
diff --git a/src/fuzzy/dzl-fuzzy-util.c b/src/util/dzl-variant.c
similarity index 85%
rename from src/fuzzy/dzl-fuzzy-util.c
rename to src/util/dzl-variant.c
index 2175bdd..f0d592a 100644
--- a/src/fuzzy/dzl-fuzzy-util.c
+++ b/src/util/dzl-variant.c
@@ -1,6 +1,6 @@
-/* dzl-fuzzy-util.c
+/* dzl-variant.c
  *
- * Copyright (C) 2016 Christian Hergert <chergert redhat com>
+ * Copyright (C) 2016-2017 Christian Hergert <chergert redhat com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -16,12 +16,12 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#define G_LOG_DOMAIN "dzl-fuzzy-util"
+#define G_LOG_DOMAIN "dzl-variant"
 
-#include "dzl-fuzzy-util.h"
+#include "util/dzl-variant.h"
 
 guint
-fuzzy_g_variant_hash (gconstpointer data)
+dzl_g_variant_hash (gconstpointer data)
 {
   GVariant *variant = (GVariant *)data;
   GBytes *bytes;
diff --git a/src/fuzzy/dzl-fuzzy-util.h b/src/util/dzl-variant.h
similarity index 76%
rename from src/fuzzy/dzl-fuzzy-util.h
rename to src/util/dzl-variant.h
index 5b7169e..992650f 100644
--- a/src/fuzzy/dzl-fuzzy-util.h
+++ b/src/util/dzl-variant.h
@@ -1,6 +1,6 @@
-/* dzl-fuzzy-util.h
+/* dzl-variant.h
  *
- * Copyright (C) 2016 Christian Hergert <chergert redhat com>
+ * Copyright (C) 2016-2017 Christian Hergert <chergert redhat com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -16,15 +16,15 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef DZL_FUZZY_UTIL_H
-#define DZL_FUZZY_UTIL_H
+#ifndef DZL_VARIANT_H
+#define DZL_VARIANT_H
 
 #include <glib.h>
 
 G_BEGIN_DECLS
 
-guint fuzzy_g_variant_hash (gconstpointer data);
+guint dzl_g_variant_hash (gconstpointer data);
 
 G_END_DECLS
 
-#endif /* DZL_FUZZY_UTIL_H */
+#endif /* DZL_VARIANT_H */


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