gui: remove suffix tree search cache

This commit is contained in:
Skylot 2016-03-08 15:00:19 +03:00
parent 218c39b1ec
commit 7cba2c3f81
9 changed files with 9 additions and 84 deletions

View File

@ -8,7 +8,6 @@ dependencies {
compile 'com.fifesoft:rsyntaxtextarea:2.5.8'
compile 'com.google.code.gson:gson:2.3.1'
compile files('libs/jfontchooser-1.0.5.jar')
compile 'com.googlecode.concurrent-trees:concurrent-trees:2.4.0'
}
applicationDistribution.with {

View File

@ -60,9 +60,7 @@ public class BackgroundWorker extends SwingWorker<Void, Void> {
LOG.debug("Memory usage: After gc: {}", Utils.memoryInfo());
TextSearchIndex searchIndex = cache.getTextIndex();
if (cache.getIndexJob().isUseFastSearch()
&& searchIndex != null
&& searchIndex.getSkippedCount() > 0) {
if (searchIndex != null && searchIndex.getSkippedCount() > 0) {
LOG.warn("Indexing of some classes skipped, count: {}, low memory: {}",
searchIndex.getSkippedCount(), Utils.memoryInfo());
}

View File

@ -21,17 +21,15 @@ public class IndexJob extends BackgroundJob {
private static final Logger LOG = LoggerFactory.getLogger(IndexJob.class);
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);
this.useFastSearch = useFastSearch;
this.cache = cache;
}
protected void runJob() {
JNodeCache nodeCache = cache.getNodeCache();
final TextSearchIndex index = new TextSearchIndex(nodeCache, useFastSearch);
final TextSearchIndex index = new TextSearchIndex(nodeCache);
final CodeUsageInfo usageInfo = new CodeUsageInfo(nodeCache);
cache.setTextIndex(index);
cache.setUsageInfo(usageInfo);
@ -73,8 +71,4 @@ public class IndexJob extends BackgroundJob {
public String getInfoString() {
return "Indexing: ";
}
public boolean isUseFastSearch() {
return useFastSearch;
}
}

View File

@ -31,7 +31,6 @@ public class JadxSettings extends JadxCLIArgs {
private boolean checkForUpdates = true;
private List<String> recentFiles = new ArrayList<String>();
private String fontStr = "";
private boolean useFastSearch = false;
private boolean autoStartJobs = true;
private Map<String, WindowLocation> windowPos = new HashMap<String, WindowLocation>();
@ -169,15 +168,6 @@ public class JadxSettings extends JadxCLIArgs {
this.escapeUnicode = escapeUnicode;
}
public boolean isUseFastSearch() {
return false;
// return useFastSearch;
}
public void setUseFastSearch(boolean useFastSearch) {
this.useFastSearch = useFastSearch;
}
public boolean isAutoStartJobs() {
return autoStartJobs;
}

View File

@ -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"));
other.addRow(NLS.str("preferences.check_for_updates"), update);
other.addRow(NLS.str("preferences.cfg"), cfg);
other.addRow(NLS.str("preferences.raw_cfg"), rawCfg);
other.addRow(NLS.str("preferences.fast_search"), fastSearch);
return other;
}

View File

@ -200,7 +200,7 @@ public class MainWindow extends JFrame {
// TODO: decompilation freezes sometime with several threads
int threadsCount = 1; // settings.getThreadsCount();
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() {

View File

@ -1,39 +0,0 @@
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();
}
}

View File

@ -22,7 +22,6 @@ public class TextSearchIndex {
private static final Logger LOG = LoggerFactory.getLogger(TextSearchIndex.class);
private final JNodeCache nodeCache;
private final boolean useFastSearch;
private SearchIndex<JNode> clsNamesIndex;
private SearchIndex<JNode> mthNamesIndex;
@ -31,17 +30,12 @@ public class TextSearchIndex {
private List<JavaClass> skippedClasses = new ArrayList<JavaClass>();
public TextSearchIndex(JNodeCache nodeCache, boolean useFastSearch) {
public TextSearchIndex(JNodeCache nodeCache) {
this.nodeCache = nodeCache;
this.useFastSearch = useFastSearch;
this.clsNamesIndex = initIndex();
this.mthNamesIndex = initIndex();
this.fldNamesIndex = initIndex();
this.codeIndex = useFastSearch ? new SuffixTree<CodeNode>() : new CodeIndex<CodeNode>();
}
private <T> SearchIndex<T> initIndex() {
return useFastSearch ? new SuffixTree<T>() : new SimpleIndex<T>();
this.clsNamesIndex = new SimpleIndex<JNode>();
this.mthNamesIndex = new SimpleIndex<JNode>();
this.fldNamesIndex = new SimpleIndex<JNode>();
this.codeIndex = new CodeIndex<CodeNode>();
}
public void indexNames(JavaClass cls) {

View File

@ -64,7 +64,6 @@ preferences.threads=Processing threads count
preferences.cfg=Generate methods CFG graphs (in 'dot' format)
preferences.raw_cfg=Generate RAW CFG graphs
preferences.font=Editor font
preferences.fast_search=Fast search (uses more memory)
preferences.start_jobs=Auto start background decompilation
preferences.select_font=Select
preferences.deobfuscation_on=Enable deobfuscation