aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSubclassMap.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSubclassMap.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSubclassMap.java
index 290b534454..6162c221a3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSubclassMap.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSubclassMap.java
@@ -67,6 +67,8 @@ public class ObjectIdSubclassMap<V extends ObjectId> implements Iterable<V> {
private int size;
+ private int grow;
+
private int mask;
private V[] table;
@@ -127,10 +129,9 @@ public class ObjectIdSubclassMap<V extends ObjectId> implements Iterable<V> {
* type of instance to store.
*/
public <Q extends V> void add(final Q newValue) {
- if (table.length - 1 <= size * 2)
+ if (++size == grow)
grow();
insert(newValue);
- size++;
}
/**
@@ -164,13 +165,12 @@ public class ObjectIdSubclassMap<V extends ObjectId> implements Iterable<V> {
i = 0;
}
- if (table.length - 1 <= size * 2) {
+ if (++size == grow) {
grow();
insert(newValue);
} else {
table[i] = newValue;
}
- size++;
return newValue;
}
@@ -239,6 +239,7 @@ public class ObjectIdSubclassMap<V extends ObjectId> implements Iterable<V> {
}
private void initTable(int sz) {
+ grow = sz >> 1;
mask = sz - 1;
table = createArray(sz);
}