]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Use stable hash for methods in HashMap of implicit_implementations a522301fedac956ab0df8fd074ccbfa81d7c0c52
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 7 May 2020 18:58:36 +0000 (20:58 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 7 May 2020 19:07:33 +0000 (21:07 +0200)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/990

vala/valaclass.vala
vala/valasymbol.vala

index 586fe287f86a6a23d33260404fdc38a6b6272b84..9d71a4239cafa5fa1fb362e25bb9fe6831842fe7 100644 (file)
@@ -116,7 +116,7 @@ public class Vala.Class : ObjectTypeSymbol {
        private bool? _is_singleton;
 
        private List<DataType> base_types = new ArrayList<DataType> ();
-       private HashMap<Method,Method> implicit_implementations = new HashMap<Method,Method> ();
+       private HashMap<Method,Method> implicit_implementations = new HashMap<Method,Method> (Symbol.hash_func, Symbol.equal_func);
 
        /**
         * Specifies the default construction method.
index 790ddd9b90252e3362f182a7a0abdb70dcb7fb52..6b1c7f665ad61fe7ccad14d62499eb5654085e3b 100644 (file)
@@ -321,6 +321,27 @@ public abstract class Vala.Symbol : CodeNode {
                return result_builder.str;
        }
 
+       /**
+        * Implementation of GLib.EqualFunc to use with e.g. HashMap
+        *
+        * @param a a symbol
+        * @param b a symbol
+        * @return whether the given instances represent the same symbol
+        */
+       public static bool equal_func (Symbol a, Symbol b) {
+               return str_equal (a.get_full_name (), b.get_full_name ());
+       }
+
+       /**
+        * Implementation of GLib.HashFunc to use with e.g. HashMap
+        *
+        * @param s a symbol
+        * @return a hash value
+        */
+       public static uint hash_func (Symbol s) {
+               return str_hash (s.get_full_name ());
+       }
+
        // get the top scope from where this symbol is still accessible
        public Scope? get_top_accessible_scope (bool is_internal = false) {
                if (access == SymbolAccessibility.PRIVATE) {