From 81fb6092af5cfc9a4562f8c9f4d92227340bc4bc Mon Sep 17 00:00:00 2001 From: BJ Hargrave Date: Fri, 6 May 2022 10:03:35 -0400 Subject: [PATCH] immutable: Remove a variable store in a loop This also makes reading the loop more clear that it is incrementing the index by 2 each iteration. Signed-off-by: BJ Hargrave --- .../src/aQute/bnd/unmodifiable/ImmutableMap.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/biz.aQute.bnd.util/src/aQute/bnd/unmodifiable/ImmutableMap.java b/biz.aQute.bnd.util/src/aQute/bnd/unmodifiable/ImmutableMap.java index a59694fef4..86b1239b95 100644 --- a/biz.aQute.bnd.util/src/aQute/bnd/unmodifiable/ImmutableMap.java +++ b/biz.aQute.bnd.util/src/aQute/bnd/unmodifiable/ImmutableMap.java @@ -42,14 +42,14 @@ private static short[] hash(Object[] entries) { throw new IllegalArgumentException("map too large: " + length); } short[] hash_bucket = new short[length * 2]; - for (int slot = 0, index = 0; slot < length;) { - Object key = entries[index++]; + for (int slot = 0, index = 0; slot < length; index += 2) { + Object key = entries[index]; int hash = -1 - linear_probe(entries, hash_bucket, key); if (hash < 0) { throw new IllegalArgumentException("duplicate key: " + key); } hash_bucket[hash] = (short) ++slot; - requireNonNull(entries[index++]); + requireNonNull(entries[index + 1]); } return hash_bucket; }