mirror of
https://github.com/GTNewHorizons/GTNHLib.git
synced 2026-11-28 23:39:08 +00:00
add back and mark deprecated ClassConstantPoolParser#addString method (#291)
This commit is contained in:
1 parent
a0d7643ed1
commit
d1abde1426
1 file changed
+11
-4
@@ -23,6 +23,7 @@
|
||||
package com.gtnewhorizon.gtnhlib.asm;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Using this class to search for a (single) String reference is > 40 times faster than parsing a class with a
|
||||
@@ -74,10 +75,7 @@ public final class ClassConstantPoolParser {
|
||||
}
|
||||
}
|
||||
|
||||
// the strings to search should not be resized
|
||||
// during runtime to avoid becoming less performant
|
||||
// than using ASM directly
|
||||
private final byte[][] BYTES_TO_SEARCH;
|
||||
private byte[][] BYTES_TO_SEARCH;
|
||||
|
||||
public ClassConstantPoolParser(String... strings) {
|
||||
BYTES_TO_SEARCH = new byte[strings.length][];
|
||||
@@ -86,6 +84,15 @@ public final class ClassConstantPoolParser {
|
||||
}
|
||||
}
|
||||
|
||||
/// the strings to search should not be resized
|
||||
/// during runtime to avoid becoming less performant
|
||||
/// than using ASM directly
|
||||
@Deprecated
|
||||
public void addString(String string) {
|
||||
BYTES_TO_SEARCH = Arrays.copyOf(BYTES_TO_SEARCH, BYTES_TO_SEARCH.length + 1);
|
||||
BYTES_TO_SEARCH[BYTES_TO_SEARCH.length - 1] = string.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the constant pool of the class represented by this byte array contains one of the Strings we are
|
||||
* looking for
|
||||
|
||||
Reference in new issue
Block a user