From d092473fe401a5a668e57f054efbd1e84ac6ca59 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Mon, 6 Feb 2023 21:13:33 +0100 Subject: Improve history sync under load --- libdino/src/util/weak_map.vala | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'libdino/src/util') diff --git a/libdino/src/util/weak_map.vala b/libdino/src/util/weak_map.vala index 0fd9d55d..a7f4bc44 100644 --- a/libdino/src/util/weak_map.vala +++ b/libdino/src/util/weak_map.vala @@ -22,12 +22,11 @@ public class WeakMap : Gee.AbstractMap { hash_map = new HashMap(); notify_map = new HashMap(); } else { - hash_map = new HashMap((v) => { return this.key_hash_func(v); }, - (a, b) => { return this.key_equal_func(a, b); }, - (a, b) => { return this.value_equal_func(a, b); }); - notify_map = new HashMap((v) => { return this.key_hash_func(v); }, - (a, b) => { return this.key_equal_func(a, b); }, - (a, b) => { return this.value_equal_func(a, b); }); + hash_map = new HashMap((v) => { return this.key_hash_func != null ? this.key_hash_func(v) : 0; }, + (a, b) => { return this.key_equal_func != null ? this.key_equal_func(a, b) : a == b; }, + (a, b) => { return this.value_equal_func != null ? this.value_equal_func(a, b) : a == b; }); + notify_map = new HashMap((v) => { return this.key_hash_func != null ? this.key_hash_func(v) : 0; }, + (a, b) => { return this.key_equal_func != null ? this.key_equal_func(a, b) : a == b; }); } } @@ -49,7 +48,7 @@ public class WeakMap : Gee.AbstractMap { } public override bool has(K key, V value) { - assert_not_reached(); + return has_key(key) && (this.value_equal_func != null ? this.value_equal_func(hash_map[key], value) : hash_map[key] == value); } public override bool has_key(K key) { -- cgit v1.2.3-54-g00ecf