mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Minor optimization (empty map creation avoided)
This commit is contained in:
@@ -34,10 +34,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.Reference;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@@ -244,17 +241,18 @@ public class JarHandlerBase {
|
||||
@NotNull
|
||||
protected Map<String, EntryInfo> getEntriesMap() {
|
||||
synchronized (lock) {
|
||||
Map<String, EntryInfo> map = myRelPathsToEntries != null ? myRelPathsToEntries.get() : null;
|
||||
Map<String, EntryInfo> map = SoftReference.dereference(myRelPathsToEntries);
|
||||
|
||||
if (map == null) {
|
||||
final JarFile zip = getJar();
|
||||
LogUtil.debug(LOG, "mapping %s", myBasePath);
|
||||
|
||||
map = new THashMap<String, EntryInfo>();
|
||||
if (zip != null) {
|
||||
LogUtil.debug(LOG, "mapping %s", myBasePath);
|
||||
|
||||
map = new THashMap<String, EntryInfo>();
|
||||
map.put("", new EntryInfo("", null, true));
|
||||
final Enumeration<? extends JarFile.JarEntry> entries = zip.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
JarFile.JarEntry entry = entries.nextElement();
|
||||
final JarFile.JarEntry entry = entries.nextElement();
|
||||
final String name = entry.getName();
|
||||
final boolean isDirectory = StringUtil.endsWithChar(name, '/');
|
||||
getOrCreate(isDirectory ? name.substring(0, name.length() - 1) : name, isDirectory, map);
|
||||
@@ -262,7 +260,11 @@ public class JarHandlerBase {
|
||||
|
||||
myRelPathsToEntries = new SoftReference<Map<String, EntryInfo>>(map);
|
||||
}
|
||||
else {
|
||||
map = Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user