From 7279bda2277d772ea8da2ae31e31dd183f84c609 Mon Sep 17 00:00:00 2001 From: Carlos Sobrinho Date: Thu, 10 Oct 2019 18:30:37 -0700 Subject: [PATCH] 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. --- src/main/javassist/ClassPoolTail.java | 8 ++++---- 1 file 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 jarfileEntries; + Set jarfileEntries; String jarfileURL; JarClassPath(String pathname) throws NotFoundException { JarFile jarfile = null; try { jarfile = new JarFile(pathname); - jarfileEntries = new ArrayList(); + jarfileEntries = new HashSet(); for (JarEntry je:Collections.list(jarfile.entries())) if (je.getName().endsWith(".class")) jarfileEntries.add(je.getName()); -- 2.39.5