From e39c712757a85f5cf6e4264e471616afa051ace7 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sun, 8 Dec 2024 14:50:10 -0500 Subject: [PATCH] Internal refactoring --- .../commons/collections4/map/MultiKeyMap.java | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java b/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java index 3876db2b5..e58091c15 100644 --- a/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java +++ b/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java @@ -25,6 +25,7 @@ import java.util.Objects; import org.apache.commons.collections4.MapIterator; import org.apache.commons.collections4.keyvalue.MultiKey; +import org.apache.commons.collections4.map.AbstractHashedMap.HashEntry; /** * A {@code Map} implementation that uses multiple keys to map the value. @@ -163,8 +164,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = - decorated().data[decorated().hashIndex(hashCode, decorated().data.length)]; + AbstractHashedMap.HashEntry, V> entry = decoratedHashEntry(hashCode); while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2)) { return true; @@ -184,8 +184,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = - decorated().data[decorated().hashIndex(hashCode, decorated().data.length)]; + AbstractHashedMap.HashEntry, V> entry = decoratedHashEntry(hashCode); while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3)) { return true; @@ -206,8 +205,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = - decorated().data[decorated().hashIndex(hashCode, decorated().data.length)]; + AbstractHashedMap.HashEntry, V> entry = decoratedHashEntry(hashCode); while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4)) { return true; @@ -227,11 +225,9 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = - decorated().data[decorated().hashIndex(hashCode, decorated().data.length)]; + AbstractHashedMap.HashEntry, V> entry = decoratedHashEntry(hashCode); while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5)) { return true; @@ -249,6 +245,14 @@ public class MultiKeyMap extends AbstractMapDecorator, V>) super.decorated(); } + HashEntry, V> decoratedHashEntry(final int hashCode) { + return decorated().data[decoratedHashIndex(hashCode)]; + } + + int decoratedHashIndex(final int hashCode) { + return decorated().hashIndex(hashCode, decorated().data.length); + } + /** * Gets the value mapped to the specified multi-key. * @@ -258,8 +262,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = - decorated().data[decorated().hashIndex(hashCode, decorated().data.length)]; + AbstractHashedMap.HashEntry, V> entry = decoratedHashEntry(hashCode); while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2)) { return entry.getValue(); @@ -279,8 +282,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = - decorated().data[decorated().hashIndex(hashCode, decorated().data.length)]; + AbstractHashedMap.HashEntry, V> entry = decoratedHashEntry(hashCode); while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3)) { return entry.getValue(); @@ -301,8 +303,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = - decorated().data[decorated().hashIndex(hashCode, decorated().data.length)]; + AbstractHashedMap.HashEntry, V> entry = decoratedHashEntry(hashCode); while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4)) { return entry.getValue(); @@ -324,8 +325,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = - decorated().data[decorated().hashIndex(hashCode, decorated().data.length)]; + AbstractHashedMap.HashEntry, V> entry = decoratedHashEntry(hashCode); while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5)) { return entry.getValue(); @@ -545,7 +545,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5)) { @@ -571,7 +571,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4)) { @@ -596,7 +596,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3)) { @@ -620,7 +620,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; while (entry != null) { if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2)) { @@ -797,7 +797,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; AbstractHashedMap.HashEntry, V> previous = null; while (entry != null) { @@ -823,7 +823,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; AbstractHashedMap.HashEntry, V> previous = null; while (entry != null) { @@ -850,7 +850,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; AbstractHashedMap.HashEntry, V> previous = null; while (entry != null) { @@ -879,7 +879,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V> entry = decorated().data[index]; AbstractHashedMap.HashEntry, V> previous = null; while (entry != null) {