[gnome-games/wip/exalm/uid: 11/16] uid: Add Uid.hash()



commit d1836522b45b584e76f55ca2994a9566d0fa76b1
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu Mar 5 22:49:01 2020 +0500

    uid: Add Uid.hash()

 src/core/game.vala | 4 +---
 src/core/uid.vala  | 4 ++++
 2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/core/game.vala b/src/core/game.vala
index 7a4c6b6a..8d0d5644 100644
--- a/src/core/game.vala
+++ b/src/core/game.vala
@@ -68,9 +68,7 @@ public class Games.Game : Object {
        }
 
        public static uint hash (Game key) {
-               var uid = key.uid.to_string ();
-
-               return str_hash (uid);
+               return Uid.hash (key.uid);
        }
 
        public static bool equal (Game a, Game b) {
diff --git a/src/core/uid.vala b/src/core/uid.vala
index 7bde6bf5..921de72a 100644
--- a/src/core/uid.vala
+++ b/src/core/uid.vala
@@ -10,4 +10,8 @@ public class Games.Uid : Object {
        public string to_string () {
                return uid;
        }
+
+       public static uint hash (Uid key) {
+               return str_hash (key.uid);
+       }
 }


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