diff --git a/pom.xml b/pom.xml
index edf3689..647f3c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
G-Earth
G-Wasm
- 1.0
+ 1.0.1
diff --git a/src/main/java/wasm/GWasm.java b/src/main/java/wasm/GWasm.java
index df4d90f..12fc7bc 100644
--- a/src/main/java/wasm/GWasm.java
+++ b/src/main/java/wasm/GWasm.java
@@ -1,31 +1,10 @@
package wasm;
import wasm.disassembly.InvalidOpCodeException;
-import wasm.disassembly.instructions.Expression;
-import wasm.disassembly.instructions.Instr;
-import wasm.disassembly.instructions.InstrType;
-import wasm.disassembly.instructions.misc.SingleByteInstr;
import wasm.disassembly.modules.Module;
-import wasm.disassembly.modules.indices.FuncIdx;
-import wasm.disassembly.modules.indices.TypeIdx;
-import wasm.disassembly.modules.sections.code.Func;
-import wasm.disassembly.modules.sections.code.Locals;
-import wasm.disassembly.modules.sections.export.Export;
-import wasm.disassembly.modules.sections.export.ExportDesc;
-import wasm.disassembly.modules.sections.imprt.Import;
-import wasm.disassembly.modules.sections.imprt.ImportDesc;
-import wasm.disassembly.types.FuncType;
-import wasm.disassembly.types.ResultType;
-import wasm.disassembly.types.ValType;
-import wasm.misc.CodeCompare;
-import wasm.misc.Function;
import java.io.*;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
public class GWasm {
diff --git a/src/main/java/wasm/disassembly/conventions/CustomVector.java b/src/main/java/wasm/disassembly/conventions/CustomVector.java
index 0b77e16..63763a0 100644
--- a/src/main/java/wasm/disassembly/conventions/CustomVector.java
+++ b/src/main/java/wasm/disassembly/conventions/CustomVector.java
@@ -18,7 +18,7 @@ public class CustomVector extends WASMOpCode {
public CustomVector(BufferedInputStream in, Creator creator, Assembler assembler, Module module) throws IOException, InvalidOpCodeException {
long length = WUnsignedInt.read(in, 32);
- elements = new ArrayList<>();
+ elements = new ArrayList<>(1);
for (int i = 0; i < length; i++) {
elements.add(creator.create(in, module));
}
diff --git a/src/main/java/wasm/disassembly/conventions/Vector.java b/src/main/java/wasm/disassembly/conventions/Vector.java
index cb728cf..d4337c5 100644
--- a/src/main/java/wasm/disassembly/conventions/Vector.java
+++ b/src/main/java/wasm/disassembly/conventions/Vector.java
@@ -17,7 +17,7 @@ public class Vector extends WASMOpCode {
public Vector(BufferedInputStream in, Creator creator, Module module) throws IOException, InvalidOpCodeException {
long length = WUnsignedInt.read(in, 32);
- elements = new ArrayList<>();
+ elements = new ArrayList<>(1);
for (int i = 0; i < length; i++) {
elements.add(creator.create(in, module));
}
diff --git a/src/main/java/wasm/disassembly/instructions/control/BlockInstr.java b/src/main/java/wasm/disassembly/instructions/control/BlockInstr.java
index 4135adc..f737d81 100644
--- a/src/main/java/wasm/disassembly/instructions/control/BlockInstr.java
+++ b/src/main/java/wasm/disassembly/instructions/control/BlockInstr.java
@@ -22,7 +22,7 @@ public class BlockInstr extends Instr {
blockType = new BlockType(in, module);
- blockInstructions = new ArrayList<>();
+ blockInstructions = new ArrayList<>(4);
InstrType type;
while ((type = InstrFactory.disassembleType(in)) != InstrType.END) {
blockInstructions.add(InstrFactory.disassemble(in, type, module));
diff --git a/src/main/java/wasm/disassembly/instructions/control/IfElseInstr.java b/src/main/java/wasm/disassembly/instructions/control/IfElseInstr.java
index 995a39a..a4fd735 100644
--- a/src/main/java/wasm/disassembly/instructions/control/IfElseInstr.java
+++ b/src/main/java/wasm/disassembly/instructions/control/IfElseInstr.java
@@ -24,14 +24,14 @@ public class IfElseInstr extends Instr {
super(instrType);
blockType = new BlockType(in, module);
- ifInstructions = new ArrayList<>();
+ ifInstructions = new ArrayList<>(2);
elseInstructions = null;
List currentBlock = ifInstructions;
InstrType type;
while ((type = InstrFactory.disassembleType(in)) != InstrType.END) {
if (type == InstrType.ELSE) {
- elseInstructions = new ArrayList<>();
+ elseInstructions = new ArrayList<>(2);
currentBlock = elseInstructions;
}
else {
diff --git a/src/main/java/wasm/disassembly/modules/Module.java b/src/main/java/wasm/disassembly/modules/Module.java
index c02f54d..6a794ad 100644
--- a/src/main/java/wasm/disassembly/modules/Module.java
+++ b/src/main/java/wasm/disassembly/modules/Module.java
@@ -2,7 +2,6 @@ package wasm.disassembly.modules;
import wasm.disassembly.InvalidOpCodeException;
import wasm.disassembly.WASMOpCode;
-import wasm.disassembly.modules.indices.FuncIdx;
import wasm.disassembly.modules.sections.Section;
import wasm.disassembly.modules.sections.code.CodeSection;
import wasm.disassembly.modules.sections.custom.CustomSection;
@@ -12,15 +11,11 @@ import wasm.disassembly.modules.sections.element.ElementSection;
import wasm.disassembly.modules.sections.export.ExportSection;
import wasm.disassembly.modules.sections.function.FunctionSection;
import wasm.disassembly.modules.sections.global.GlobalSection;
-import wasm.disassembly.modules.sections.imprt.Import;
import wasm.disassembly.modules.sections.imprt.ImportSection;
import wasm.disassembly.modules.sections.memory.MemorySection;
import wasm.disassembly.modules.sections.start.StartSection;
import wasm.disassembly.modules.sections.table.TableSection;
import wasm.disassembly.modules.sections.type.TypeSection;
-import wasm.disassembly.types.FuncType;
-import wasm.misc.CodeCompare;
-import wasm.misc.Function;
import wasm.misc.StreamReplacement;
import java.io.*;
diff --git a/src/main/java/wasm/disassembly/modules/sections/code/CodeSection.java b/src/main/java/wasm/disassembly/modules/sections/code/CodeSection.java
index 9fece18..80ecae8 100644
--- a/src/main/java/wasm/disassembly/modules/sections/code/CodeSection.java
+++ b/src/main/java/wasm/disassembly/modules/sections/code/CodeSection.java
@@ -1,8 +1,6 @@
package wasm.disassembly.modules.sections.code;
import wasm.disassembly.InvalidOpCodeException;
-import wasm.disassembly.conventions.Creator;
-import wasm.disassembly.conventions.Vector;
import wasm.disassembly.instructions.Expression;
import wasm.disassembly.instructions.Instr;
import wasm.disassembly.instructions.InstrType;
@@ -12,10 +10,7 @@ import wasm.disassembly.modules.Module;
import wasm.disassembly.modules.indices.FuncIdx;
import wasm.disassembly.modules.indices.LocalIdx;
import wasm.disassembly.modules.sections.Section;
-import wasm.disassembly.modules.sections.data.Data;
import wasm.disassembly.values.WUnsignedInt;
-import wasm.misc.CodeCompare;
-import wasm.misc.Function;
import wasm.misc.StreamReplacement;
import java.io.BufferedInputStream;
@@ -52,9 +47,8 @@ public class CodeSection extends Section {
for (int j = 0; j < module.streamReplacements.size(); j++) {
if (module.getFunctionSection().matchesSearchFunctionsTypes.get(j).contains(i)) {
- CodeCompare comparer = module.streamReplacements.get(j).getCodeCompare();
- if (comparer.isEqual(func)) {
+ if (module.streamReplacements.get(j).codeMatches(func)) {
StreamReplacement.ReplacementType actionTaken = module.streamReplacements.get(j).getReplacementType();
if (actionTaken == StreamReplacement.ReplacementType.HOOK) {
CallInstr call = new CallInstr(new FuncIdx(j, module));
diff --git a/src/main/java/wasm/disassembly/modules/sections/function/FunctionSection.java b/src/main/java/wasm/disassembly/modules/sections/function/FunctionSection.java
index 5cbe786..adb4b24 100644
--- a/src/main/java/wasm/disassembly/modules/sections/function/FunctionSection.java
+++ b/src/main/java/wasm/disassembly/modules/sections/function/FunctionSection.java
@@ -1,16 +1,10 @@
package wasm.disassembly.modules.sections.function;
import wasm.disassembly.InvalidOpCodeException;
-import wasm.disassembly.conventions.Vector;
import wasm.disassembly.modules.Module;
-import wasm.disassembly.modules.indices.FuncIdx;
import wasm.disassembly.modules.indices.TypeIdx;
import wasm.disassembly.modules.sections.Section;
-import wasm.disassembly.modules.sections.code.Code;
-import wasm.disassembly.modules.sections.code.Func;
import wasm.disassembly.values.WUnsignedInt;
-import wasm.misc.CodeCompare;
-import wasm.misc.Function;
import wasm.misc.StreamReplacement;
import java.io.BufferedInputStream;
diff --git a/src/main/java/wasm/misc/CodeCompare.java b/src/main/java/wasm/misc/CodeCompare.java
deleted file mode 100644
index 694163f..0000000
--- a/src/main/java/wasm/misc/CodeCompare.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package wasm.misc;
-
-import wasm.disassembly.modules.sections.code.Func;
-import wasm.disassembly.types.FuncType;
-
-public interface CodeCompare {
-
- boolean isEqual(Func code);
-
-}
diff --git a/src/main/java/wasm/misc/StreamReplacement.java b/src/main/java/wasm/misc/StreamReplacement.java
index 36c7d76..2aa3385 100644
--- a/src/main/java/wasm/misc/StreamReplacement.java
+++ b/src/main/java/wasm/misc/StreamReplacement.java
@@ -1,5 +1,6 @@
package wasm.misc;
+import wasm.disassembly.modules.sections.code.Func;
import wasm.disassembly.types.FuncType;
public interface StreamReplacement {
@@ -14,5 +15,5 @@ public interface StreamReplacement {
ReplacementType getReplacementType();
String getImportName();
String getExportName();
- CodeCompare getCodeCompare();
+ boolean codeMatches(Func code);
}