Correctly clean counter to fix HashedList#contains method

ported from lithium
This commit is contained in:
tr7zw 2020-09-10 20:23:55 +03:00 committed by Ivan Pekov
parent 80a494c570
commit b02e858b3e
No known key found for this signature in database
GPG Key ID: BC975C392D9CA3A3

View File

@ -8,7 +8,7 @@ you can find the original code on https://github.com/jellysquid3/lithium-fabric/
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/collections/HashedList.java b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/HashedList.java
new file mode 100644
index 0000000000000000000000000000000000000000..640e1bc80d1989f3580081d8d484059075fbd8f5
index 0000000000000000000000000000000000000000..2d79932dbd1fc386a94b8d6ea3526934c54c2aad
--- /dev/null
+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/HashedList.java
@@ -0,0 +1,280 @@
@ -283,7 +283,7 @@ index 0000000000000000000000000000000000000000..640e1bc80d1989f3580081d8d4840590
+
+ @SuppressWarnings("unchecked")
+ private void trackReferenceRemoved(Object o) {
+ if (this.counter.addTo((T) o, -1) <= 0) {
+ if (this.counter.addTo((T) o, -1) <= 1) {
+ this.counter.removeInt(o);
+ }
+ }