mirror of
https://github.com/moparisthebest/fernflower
synced 2024-10-31 15:35:08 -04:00
java-decompiler: minor optimization (no more empty array creation)
This commit is contained in:
parent
8462998a86
commit
bef17b44fc
@ -17,6 +17,7 @@ package org.jetbrains.java.decompiler.struct.attr;
|
|||||||
|
|
||||||
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
import org.jetbrains.java.decompiler.struct.consts.ConstantPool;
|
||||||
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
import org.jetbrains.java.decompiler.util.DataInputFullStream;
|
||||||
|
import org.jetbrains.java.decompiler.util.InterpreterUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ import java.io.IOException;
|
|||||||
* Created by Egor on 05.10.2014.
|
* Created by Egor on 05.10.2014.
|
||||||
*/
|
*/
|
||||||
public class StructLineNumberTableAttribute extends StructGeneralAttribute {
|
public class StructLineNumberTableAttribute extends StructGeneralAttribute {
|
||||||
private int[] myLineInfo = new int[0];
|
private int[] myLineInfo = InterpreterUtil.EMPTY_INT_ARRAY;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initContent(ConstantPool pool) throws IOException {
|
public void initContent(ConstantPool pool) throws IOException {
|
||||||
@ -44,7 +45,7 @@ public class StructLineNumberTableAttribute extends StructGeneralAttribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (myLineInfo.length > 0) {
|
else if (myLineInfo.length > 0) {
|
||||||
myLineInfo = new int[0];
|
myLineInfo = InterpreterUtil.EMPTY_INT_ARRAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ public class FastSparseSetFactory<E> {
|
|||||||
|
|
||||||
|
|
||||||
public static class FastSparseSet<E> implements Iterable<E> {
|
public static class FastSparseSet<E> implements Iterable<E> {
|
||||||
|
public static final FastSparseSet[] EMPTY_ARRAY = new FastSparseSet[0];
|
||||||
|
|
||||||
private FastSparseSetFactory<E> factory;
|
private FastSparseSetFactory<E> factory;
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ import java.util.zip.ZipFile;
|
|||||||
public class InterpreterUtil {
|
public class InterpreterUtil {
|
||||||
public static final boolean IS_WINDOWS = System.getProperty("os.name", "").startsWith("Windows");
|
public static final boolean IS_WINDOWS = System.getProperty("os.name", "").startsWith("Windows");
|
||||||
|
|
||||||
|
public static final int[] EMPTY_INT_ARRAY = new int[0];
|
||||||
|
|
||||||
private static final int CHANNEL_WINDOW_SIZE = IS_WINDOWS ? 64 * 1024 * 1024 - (32 * 1024) : 64 * 1024 * 1024; // magic number for Windows
|
private static final int CHANNEL_WINDOW_SIZE = IS_WINDOWS ? 64 * 1024 * 1024 - (32 * 1024) : 64 * 1024 * 1024; // magic number for Windows
|
||||||
private static final int BUFFER_SIZE = 16 * 1024;
|
private static final int BUFFER_SIZE = 16 * 1024;
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ public class SFormsFastMapDirect {
|
|||||||
private SFormsFastMapDirect(boolean initialize) {
|
private SFormsFastMapDirect(boolean initialize) {
|
||||||
if (initialize) {
|
if (initialize) {
|
||||||
for (int i = 2; i >= 0; i--) {
|
for (int i = 2; i >= 0; i--) {
|
||||||
@SuppressWarnings("unchecked") FastSparseSet<Integer>[] empty = new FastSparseSet[0];
|
@SuppressWarnings("unchecked") FastSparseSet<Integer>[] empty = FastSparseSet.EMPTY_ARRAY;
|
||||||
elements[i] = empty;
|
elements[i] = empty;
|
||||||
next[i] = new int[0];
|
next[i] = InterpreterUtil.EMPTY_INT_ARRAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,8 +99,8 @@ public class SFormsFastMapDirect {
|
|||||||
while (pointer != 0);
|
while (pointer != 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mapelements[i] = new FastSparseSet[0];
|
mapelements[i] = FastSparseSet.EMPTY_ARRAY;
|
||||||
mapnext[i] = new int[0];
|
mapnext[i] = InterpreterUtil.EMPTY_INT_ARRAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user