diff options
author | Carlos Sobrinho <sobrinho@google.com> | 2019-10-10 18:30:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-10 18:30:37 -0700 |
commit | 7279bda2277d772ea8da2ae31e31dd183f84c609 (patch) | |
tree | 597ec66dab99fa65284c2fdd4c746e2d2afbdb61 | |
parent | 30627914d3f40b9a9bf88f57cd616e70dfdda97f (diff) | |
download | javassist-7279bda2277d772ea8da2ae31e31dd183f84c609.tar.gz javassist-7279bda2277d772ea8da2ae31e31dd183f84c609.zip |
Fix a bottleneck. If the jar entries is big, List.contains is O(n) and very slow!
This is a continuation of #271 to speed up the 3.25/26 release. More details on the issue.
-rw-r--r-- | src/main/javassist/ClassPoolTail.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main/javassist/ClassPoolTail.java b/src/main/javassist/ClassPoolTail.java index d9d2198e..72fa390c 100644 --- a/src/main/javassist/ClassPoolTail.java +++ b/src/main/javassist/ClassPoolTail.java @@ -25,9 +25,9 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -128,14 +128,14 @@ final class JarDirClassPath implements ClassPath { } final class JarClassPath implements ClassPath { - List<String> jarfileEntries; + Set<String> jarfileEntries; String jarfileURL; JarClassPath(String pathname) throws NotFoundException { JarFile jarfile = null; try { jarfile = new JarFile(pathname); - jarfileEntries = new ArrayList<String>(); + jarfileEntries = new HashSet<String>(); for (JarEntry je:Collections.list(jarfile.entries())) if (je.getName().endsWith(".class")) jarfileEntries.add(je.getName()); |