Browse Source

Merge pull request #279 from csobrinho/patch-1

Fix a bottleneck. If the jar entries is big, List.contains is O(n) an…
tags/rel_3_27_0_ga
Shigeru Chiba 4 years ago
parent
commit
a54eae58df
No account linked to committer's email address
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      src/main/javassist/ClassPoolTail.java

+ 4
- 4
src/main/javassist/ClassPoolTail.java View File

import java.io.OutputStream; import java.io.OutputStream;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList;
import java.util.Collections; 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.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;


} }


final class JarClassPath implements ClassPath { final class JarClassPath implements ClassPath {
List<String> jarfileEntries;
Set<String> jarfileEntries;
String jarfileURL; String jarfileURL;


JarClassPath(String pathname) throws NotFoundException { JarClassPath(String pathname) throws NotFoundException {
JarFile jarfile = null; JarFile jarfile = null;
try { try {
jarfile = new JarFile(pathname); jarfile = new JarFile(pathname);
jarfileEntries = new ArrayList<String>();
jarfileEntries = new HashSet<String>();
for (JarEntry je:Collections.list(jarfile.entries())) for (JarEntry je:Collections.list(jarfile.entries()))
if (je.getName().endsWith(".class")) if (je.getName().endsWith(".class"))
jarfileEntries.add(je.getName()); jarfileEntries.add(je.getName());

Loading…
Cancel
Save