Commit 7cba2c3f authored by Skylot's avatar Skylot

gui: remove suffix tree search cache

parent 218c39b1
...@@ -8,7 +8,6 @@ dependencies { ...@@ -8,7 +8,6 @@ dependencies {
compile 'com.fifesoft:rsyntaxtextarea:2.5.8' compile 'com.fifesoft:rsyntaxtextarea:2.5.8'
compile 'com.google.code.gson:gson:2.3.1' compile 'com.google.code.gson:gson:2.3.1'
compile files('libs/jfontchooser-1.0.5.jar') compile files('libs/jfontchooser-1.0.5.jar')
compile 'com.googlecode.concurrent-trees:concurrent-trees:2.4.0'
} }
applicationDistribution.with { applicationDistribution.with {
......
...@@ -60,9 +60,7 @@ public class BackgroundWorker extends SwingWorker<Void, Void> { ...@@ -60,9 +60,7 @@ public class BackgroundWorker extends SwingWorker<Void, Void> {
LOG.debug("Memory usage: After gc: {}", Utils.memoryInfo()); LOG.debug("Memory usage: After gc: {}", Utils.memoryInfo());
TextSearchIndex searchIndex = cache.getTextIndex(); TextSearchIndex searchIndex = cache.getTextIndex();
if (cache.getIndexJob().isUseFastSearch() if (searchIndex != null && searchIndex.getSkippedCount() > 0) {
&& searchIndex != null
&& searchIndex.getSkippedCount() > 0) {
LOG.warn("Indexing of some classes skipped, count: {}, low memory: {}", LOG.warn("Indexing of some classes skipped, count: {}, low memory: {}",
searchIndex.getSkippedCount(), Utils.memoryInfo()); searchIndex.getSkippedCount(), Utils.memoryInfo());
} }
......
...@@ -21,17 +21,15 @@ public class IndexJob extends BackgroundJob { ...@@ -21,17 +21,15 @@ public class IndexJob extends BackgroundJob {
private static final Logger LOG = LoggerFactory.getLogger(IndexJob.class); private static final Logger LOG = LoggerFactory.getLogger(IndexJob.class);
private final CacheObject cache; private final CacheObject cache;
private final boolean useFastSearch;
public IndexJob(JadxWrapper wrapper, CacheObject cache, int threadsCount, boolean useFastSearch) { public IndexJob(JadxWrapper wrapper, CacheObject cache, int threadsCount) {
super(wrapper, threadsCount); super(wrapper, threadsCount);
this.useFastSearch = useFastSearch;
this.cache = cache; this.cache = cache;
} }
protected void runJob() { protected void runJob() {
JNodeCache nodeCache = cache.getNodeCache(); JNodeCache nodeCache = cache.getNodeCache();
final TextSearchIndex index = new TextSearchIndex(nodeCache, useFastSearch); final TextSearchIndex index = new TextSearchIndex(nodeCache);
final CodeUsageInfo usageInfo = new CodeUsageInfo(nodeCache); final CodeUsageInfo usageInfo = new CodeUsageInfo(nodeCache);
cache.setTextIndex(index); cache.setTextIndex(index);
cache.setUsageInfo(usageInfo); cache.setUsageInfo(usageInfo);
...@@ -73,8 +71,4 @@ public class IndexJob extends BackgroundJob { ...@@ -73,8 +71,4 @@ public class IndexJob extends BackgroundJob {
public String getInfoString() { public String getInfoString() {
return "Indexing: "; return "Indexing: ";
} }
public boolean isUseFastSearch() {
return useFastSearch;
}
} }
...@@ -31,7 +31,6 @@ public class JadxSettings extends JadxCLIArgs { ...@@ -31,7 +31,6 @@ public class JadxSettings extends JadxCLIArgs {
private boolean checkForUpdates = true; private boolean checkForUpdates = true;
private List<String> recentFiles = new ArrayList<String>(); private List<String> recentFiles = new ArrayList<String>();
private String fontStr = ""; private String fontStr = "";
private boolean useFastSearch = false;
private boolean autoStartJobs = true; private boolean autoStartJobs = true;
private Map<String, WindowLocation> windowPos = new HashMap<String, WindowLocation>(); private Map<String, WindowLocation> windowPos = new HashMap<String, WindowLocation>();
...@@ -169,15 +168,6 @@ public class JadxSettings extends JadxCLIArgs { ...@@ -169,15 +168,6 @@ public class JadxSettings extends JadxCLIArgs {
this.escapeUnicode = escapeUnicode; this.escapeUnicode = escapeUnicode;
} }
public boolean isUseFastSearch() {
return false;
// return useFastSearch;
}
public void setUseFastSearch(boolean useFastSearch) {
this.useFastSearch = useFastSearch;
}
public boolean isAutoStartJobs() { public boolean isAutoStartJobs() {
return autoStartJobs; return autoStartJobs;
} }
......
...@@ -294,20 +294,10 @@ public class JadxSettingsWindow extends JDialog { ...@@ -294,20 +294,10 @@ public class JadxSettingsWindow extends JDialog {
} }
}); });
JCheckBox fastSearch = new JCheckBox();
fastSearch.setEnabled(false);
fastSearch.setSelected(settings.isUseFastSearch());
fastSearch.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setUseFastSearch(e.getStateChange() == ItemEvent.SELECTED);
}
});
SettingsGroup other = new SettingsGroup(NLS.str("preferences.other")); SettingsGroup other = new SettingsGroup(NLS.str("preferences.other"));
other.addRow(NLS.str("preferences.check_for_updates"), update); other.addRow(NLS.str("preferences.check_for_updates"), update);
other.addRow(NLS.str("preferences.cfg"), cfg); other.addRow(NLS.str("preferences.cfg"), cfg);
other.addRow(NLS.str("preferences.raw_cfg"), rawCfg); other.addRow(NLS.str("preferences.raw_cfg"), rawCfg);
other.addRow(NLS.str("preferences.fast_search"), fastSearch);
return other; return other;
} }
......
...@@ -200,7 +200,7 @@ public class MainWindow extends JFrame { ...@@ -200,7 +200,7 @@ public class MainWindow extends JFrame {
// TODO: decompilation freezes sometime with several threads // TODO: decompilation freezes sometime with several threads
int threadsCount = 1; // settings.getThreadsCount(); int threadsCount = 1; // settings.getThreadsCount();
cacheObject.setDecompileJob(new DecompileJob(wrapper, threadsCount)); cacheObject.setDecompileJob(new DecompileJob(wrapper, threadsCount));
cacheObject.setIndexJob(new IndexJob(wrapper, cacheObject, threadsCount, settings.isUseFastSearch())); cacheObject.setIndexJob(new IndexJob(wrapper, cacheObject, threadsCount));
} }
private synchronized void runBackgroundJobs() { private synchronized void runBackgroundJobs() {
......
package jadx.gui.utils.search;
import java.util.ArrayList;
import java.util.List;
import com.googlecode.concurrenttrees.radix.node.concrete.DefaultCharArrayNodeFactory;
import com.googlecode.concurrenttrees.suffix.ConcurrentSuffixTree;
public class SuffixTree<V> extends SearchIndex<V> {
private final ConcurrentSuffixTree<V> tree;
public SuffixTree() {
this.tree = new ConcurrentSuffixTree<V>(new DefaultCharArrayNodeFactory());
}
@Override
public void put(String str, V value) {
if (str == null || str.isEmpty()) {
return;
}
tree.putIfAbsent(str, value);
}
@Override
public List<V> getValuesForKeysContaining(String str) {
Iterable<V> resultsIt = tree.getValuesForKeysContaining(str);
List<V> list = new ArrayList<V>();
for (V v : resultsIt) {
list.add(v);
}
return list;
}
@Override
public int size() {
return tree.size();
}
}
...@@ -22,7 +22,6 @@ public class TextSearchIndex { ...@@ -22,7 +22,6 @@ public class TextSearchIndex {
private static final Logger LOG = LoggerFactory.getLogger(TextSearchIndex.class); private static final Logger LOG = LoggerFactory.getLogger(TextSearchIndex.class);
private final JNodeCache nodeCache; private final JNodeCache nodeCache;
private final boolean useFastSearch;
private SearchIndex<JNode> clsNamesIndex; private SearchIndex<JNode> clsNamesIndex;
private SearchIndex<JNode> mthNamesIndex; private SearchIndex<JNode> mthNamesIndex;
...@@ -31,17 +30,12 @@ public class TextSearchIndex { ...@@ -31,17 +30,12 @@ public class TextSearchIndex {
private List<JavaClass> skippedClasses = new ArrayList<JavaClass>(); private List<JavaClass> skippedClasses = new ArrayList<JavaClass>();
public TextSearchIndex(JNodeCache nodeCache, boolean useFastSearch) { public TextSearchIndex(JNodeCache nodeCache) {
this.nodeCache = nodeCache; this.nodeCache = nodeCache;
this.useFastSearch = useFastSearch; this.clsNamesIndex = new SimpleIndex<JNode>();
this.clsNamesIndex = initIndex(); this.mthNamesIndex = new SimpleIndex<JNode>();
this.mthNamesIndex = initIndex(); this.fldNamesIndex = new SimpleIndex<JNode>();
this.fldNamesIndex = initIndex(); this.codeIndex = new CodeIndex<CodeNode>();
this.codeIndex = useFastSearch ? new SuffixTree<CodeNode>() : new CodeIndex<CodeNode>();
}
private <T> SearchIndex<T> initIndex() {
return useFastSearch ? new SuffixTree<T>() : new SimpleIndex<T>();
} }
public void indexNames(JavaClass cls) { public void indexNames(JavaClass cls) {
......
...@@ -64,7 +64,6 @@ preferences.threads=Processing threads count ...@@ -64,7 +64,6 @@ preferences.threads=Processing threads count
preferences.cfg=Generate methods CFG graphs (in 'dot' format) preferences.cfg=Generate methods CFG graphs (in 'dot' format)
preferences.raw_cfg=Generate RAW CFG graphs preferences.raw_cfg=Generate RAW CFG graphs
preferences.font=Editor font preferences.font=Editor font
preferences.fast_search=Fast search (uses more memory)
preferences.start_jobs=Auto start background decompilation preferences.start_jobs=Auto start background decompilation
preferences.select_font=Select preferences.select_font=Select
preferences.deobfuscation_on=Enable deobfuscation preferences.deobfuscation_on=Enable deobfuscation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment