Fixed a bug where exact duplication would break immutableMaps/sets

This commit is contained in:
Speiger 2021-06-25 21:14:45 +02:00
parent 9d17dc17fd
commit 4c68c925d3
2 changed files with 2 additions and 8 deletions

View File

@ -214,10 +214,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
int pos = HashUtil.mix(KEY_TO_HASH(o)) & newMask; int pos = HashUtil.mix(KEY_TO_HASH(o)) & newMask;
KEY_TYPE current = newKeys[pos]; KEY_TYPE current = newKeys[pos];
if(KEY_EQUALS_NOT_NULL(current)) { if(KEY_EQUALS_NOT_NULL(current)) {
if(KEY_EQUALS(current, o)) { if(KEY_EQUALS(current, o)) continue;
found = false;
break;
}
while(KEY_EQUALS_NOT_NULL((current = newKeys[pos = (++pos & mask)]))) { while(KEY_EQUALS_NOT_NULL((current = newKeys[pos = (++pos & mask)]))) {
if(KEY_EQUALS(current, o)) { if(KEY_EQUALS(current, o)) {
found = false; found = false;

View File

@ -187,10 +187,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
int pos = HashUtil.mix(KEY_TO_HASH(o)) & newMask; int pos = HashUtil.mix(KEY_TO_HASH(o)) & newMask;
KEY_TYPE current = newKeys[pos]; KEY_TYPE current = newKeys[pos];
if(KEY_EQUALS_NOT_NULL(current)) { if(KEY_EQUALS_NOT_NULL(current)) {
if(KEY_EQUALS(current, o)) { if(KEY_EQUALS(current, o)) continue;
found = false;
break;
}
while(KEY_EQUALS_NOT_NULL((current = newKeys[pos = (++pos & mask)]))) { while(KEY_EQUALS_NOT_NULL((current = newKeys[pos = (++pos & mask)]))) {
if(KEY_EQUALS(current, o)) { if(KEY_EQUALS(current, o)) {
found = false; found = false;