Browse Source

ObjectIdSubclassMap: Manually inline index()

This method is trivial in definition, and is called in only 3
places. Inline the method manually to ensure its really going
to be inlined by the JIT at runtime.

Change-Id: I128522af8167c07d2de6cc210573599038871dda
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.12
Shawn O. Pearce 14 years ago
parent
commit
df7b192e26
  1. 10
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSubclassMap.java

10
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSubclassMap.java

@ -92,7 +92,7 @@ public class ObjectIdSubclassMap<V extends ObjectId> implements Iterable<V> {
* @return the instance mapped to toFind, or null if no mapping exists. * @return the instance mapped to toFind, or null if no mapping exists.
*/ */
public V get(final AnyObjectId toFind) { public V get(final AnyObjectId toFind) {
int i = index(toFind); int i = toFind.w1 & mask;
V obj; V obj;
while ((obj = table[i]) != null) { while ((obj = table[i]) != null) {
@ -155,7 +155,7 @@ public class ObjectIdSubclassMap<V extends ObjectId> implements Iterable<V> {
* type of instance to store. * type of instance to store.
*/ */
public <Q extends V> V addIfAbsent(final Q newValue) { public <Q extends V> V addIfAbsent(final Q newValue) {
int i = index(newValue); int i = newValue.w1 & mask;
V obj; V obj;
while ((obj = table[i]) != null) { while ((obj = table[i]) != null) {
@ -213,12 +213,8 @@ public class ObjectIdSubclassMap<V extends ObjectId> implements Iterable<V> {
}; };
} }
private final int index(final AnyObjectId id) {
return id.w1 & mask;
}
private void insert(final V newValue) { private void insert(final V newValue) {
int j = index(newValue); int j = newValue.w1 & mask;
while (table[j] != null) { while (table[j] != null) {
if (++j >= table.length) if (++j >= table.length)
j = 0; j = 0;

Loading…
Cancel
Save