diff options
author | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-10-04 14:04:54 +0200 |
---|---|---|
committer | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-10-04 14:04:54 +0200 |
commit | 0c4fcbe674f5aae34f0fee2380de6c001a167d1b (patch) | |
tree | 98ebdd43c20e600ef3d3c39126009930b56b7f87 /rules.js | |
parent | ecf109f6096d1b6c82e5eae64ed5d0bc5638f372 (diff) | |
download | algeria-0c4fcbe674f5aae34f0fee2380de6c001a167d1b.tar.gz |
GC optimization
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -2028,11 +2028,11 @@ function set_toggle(set, item) { return array_insert(set, a, item) } -function is_subset_with_multiplicity(set, subset) { - return subset.every(val => set.includes(val) - && subset.filter(el => el === val).length - <= - set.filter(el => el === val).length) +function is_subset_with_multiplicity(multiset, subset) { + const occurrences = (arr, val) => + arr.reduce((acc, el) => (el === val ? acc + 1 : acc), 0) + + return !subset.some(val => (occurrences(subset, val) > occurrences(multiset, val))) } // Fast deep copy for objects without cycles |