diff options
| author | Marvin W <git@larma.de> | 2023-02-06 21:13:33 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-10-05 14:32:06 +0200 |
| commit | 55374331bec0d79fc23d2b1291ed544b0b3d4094 (patch) | |
| tree | 37490dfb67eca626f1052e5e91080fb722ad999f /libdino/src/util/weak_map.vala | |
| parent | 7d3498a8338612a0469534506890407955ceaf60 (diff) | |
| download | dino-55374331bec0d79fc23d2b1291ed544b0b3d4094.tar.gz | |
Improve history sync under load
Diffstat (limited to 'libdino/src/util/weak_map.vala')
| -rw-r--r-- | libdino/src/util/weak_map.vala | 13 |
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) { |
