Use an ArrayList in AbstractCoordHashMap

LinkedList#get is O(n)
ArrayList#get is O(1)
We were seeing a performance loss with getEntry so this should improve
things.

The resize amount was made larger so we're not doing it as often.

Signed-off-by: Jadon Fowler <j@jadon.io>
This commit is contained in:
Jadon Fowler 2019-04-08 19:07:03 -04:00
parent 689ebb216b
commit bc0ba18738
No known key found for this signature in database
GPG Key ID: C7FF05F3C377725C
1 changed files with 3 additions and 7 deletions

View File

@ -14,10 +14,7 @@
*/
package fr.neatmonster.nocheatplus.utilities.ds.map;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
/**
* Intended for Minecraft coordinates, probably not for too high values.<br>
@ -139,13 +136,12 @@ public abstract class AbstractCoordHashMap<V, E extends fr.neatmonster.nocheatpl
}
}
} else if (size + 1 > entries.length * loadFactor) {
resize(size + 1);
resize((int) Math.floor(size * 1.25));
slot = absHash % entries.length;
bucket = entries[slot];
}
if (bucket == null) {
// TODO: use array list ?
bucket = new LinkedList<E>();
bucket = new ArrayList<E>();
entries[slot] = bucket;
}
bucket.add(newEntry(x, y, z, value, hash));