aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/util/weak_map.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2023-02-06 21:13:33 +0100
committerMarvin W <git@larma.de>2023-02-07 10:50:45 +0100
commitd092473fe401a5a668e57f054efbd1e84ac6ca59 (patch)
tree006eb67eb39226cd5bee03a54e3201f2d09818b1 /libdino/src/util/weak_map.vala
parent1d123c7e66d963fd8cc8cc4250b5813a62676f56 (diff)
downloaddino-d092473fe401a5a668e57f054efbd1e84ac6ca59.tar.gz
dino-d092473fe401a5a668e57f054efbd1e84ac6ca59.zip
Improve history sync under load
Diffstat (limited to 'libdino/src/util/weak_map.vala')
-rw-r--r--libdino/src/util/weak_map.vala13
1 files changed, 6 insertions, 7 deletions
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<K, V> : Gee.AbstractMap<K, V> {
hash_map = new HashMap<K, weak V>();
notify_map = new HashMap<K, WeakNotifyWrapper>();
} else {
- hash_map = new HashMap<K, weak V>((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<K, WeakNotifyWrapper>((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<K, weak V>((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<K, WeakNotifyWrapper>((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<K, V> : Gee.AbstractMap<K, V> {
}
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) {