ArrayList.contains shows up as a hot spot in pathfinding. Let's try using

an identity hash set to accelerate it (identity hash set uses linear probing,
which can give better cache performance than the chaining used by the normal
hash set).


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1129 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Andrzej Kapolka
2011-03-23 04:49:18 +00:00
parent ced496a379
commit 5dab9cfab2
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -67,7 +67,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>r07</version>
<version>r08</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -23,12 +23,14 @@ package com.threerings.media.util;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.awt.Point;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.samskivert.util.HashIntMap;
@@ -324,7 +326,7 @@ public class AStarPathUtil
public SortedSet<Node> open;
/** The set of closed nodes being searched. */
public ArrayList<Node> closed;
public Set<Node> closed;
/** The destination coordinates in the tile array. */
public int destx, desty;
@@ -344,7 +346,7 @@ public class AStarPathUtil
// construct the open and closed lists
open = new TreeSet<Node>();
closed = Lists.newArrayList();
closed = Sets.newIdentityHashSet();
}
/**