mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
added caching + minor size opts
This commit is contained in:
+31
-1
@@ -68,7 +68,7 @@ public class BytecodeAnalysisConverter implements ApplicationComponent {
|
||||
@Override
|
||||
public Void compute() throws IOException {
|
||||
myNamesEnumerator = new PersistentStringEnumerator(namesFile, true);
|
||||
myCompoundKeyEnumerator = new PersistentEnumeratorDelegate<int[]>(compoundKeysFile, new IntArrayKeyDescriptor(), 1024 * 4);
|
||||
myCompoundKeyEnumerator = new IntArrayPersistentEnumerator(compoundKeysFile, new IntArrayKeyDescriptor());
|
||||
return null;
|
||||
}
|
||||
}, new Runnable() {
|
||||
@@ -451,4 +451,34 @@ public class BytecodeAnalysisConverter implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private static class IntArrayPersistentEnumerator extends PersistentEnumeratorDelegate<int[]> {
|
||||
private final CachingEnumerator<int[]> myCache;
|
||||
|
||||
public IntArrayPersistentEnumerator(File compoundKeysFile, IntArrayKeyDescriptor descriptor) throws IOException {
|
||||
super(compoundKeysFile, descriptor, 1024 * 4);
|
||||
myCache = new CachingEnumerator<int[]>(new DataEnumerator<int[]>() {
|
||||
@Override
|
||||
public int enumerate(@Nullable int[] value) throws IOException {
|
||||
return IntArrayPersistentEnumerator.super.enumerate(value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public int[] valueOf(int idx) throws IOException {
|
||||
return IntArrayPersistentEnumerator.super.valueOf(idx);
|
||||
}
|
||||
}, descriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int enumerate(@Nullable int[] value) throws IOException {
|
||||
return myCache.enumerate(value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public int[] valueOf(int idx) throws IOException {
|
||||
return myCache.valueOf(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -43,7 +43,7 @@ public class BytecodeAnalysisIndex extends FileBasedIndexExtension<Integer, Coll
|
||||
private static final DataIndexer<Integer, Collection<IntIdEquation>, FileContent> INDEXER =
|
||||
new ClassDataIndexer(BytecodeAnalysisConverter.getInstance());
|
||||
|
||||
private static final int ourInternalVersion = 1;
|
||||
private static final int ourInternalVersion = 2;
|
||||
private static boolean ourEnabled = SystemProperties.getBooleanProperty("idea.enable.bytecode.contract.inference", isEnabledByDefault());
|
||||
|
||||
private static boolean isEnabledByDefault() {
|
||||
@@ -103,7 +103,7 @@ public class BytecodeAnalysisIndex extends FileBasedIndexExtension<Integer, Coll
|
||||
public static class EquationExternalizer implements DataExternalizer<Collection<IntIdEquation>> {
|
||||
@Override
|
||||
public void save(@NotNull DataOutput out, Collection<IntIdEquation> equations) throws IOException {
|
||||
out.writeInt(equations.size());
|
||||
DataInputOutputUtil.writeINT(out, equations.size());
|
||||
|
||||
for (IntIdEquation equation : equations) {
|
||||
out.writeInt(equation.id);
|
||||
@@ -132,7 +132,7 @@ public class BytecodeAnalysisIndex extends FileBasedIndexExtension<Integer, Coll
|
||||
@Override
|
||||
public Collection<IntIdEquation> read(@NotNull DataInput in) throws IOException {
|
||||
|
||||
int size = in.readInt();
|
||||
int size = DataInputOutputUtil.readINT(in);
|
||||
ArrayList<IntIdEquation> result = new ArrayList<IntIdEquation>(size);
|
||||
|
||||
for (int x = 0; x < size; x++) {
|
||||
|
||||
Reference in New Issue
Block a user