mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-02 21:41:41 +01:00
Cache compiled pattern
This commit is contained in:
parent
d3432011d9
commit
e7545e470f
@ -12,6 +12,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
final class ShapeImpl implements Shape {
|
||||
private static final Pattern PATTERN = Pattern.compile("\\d.\\d{1,3}", Pattern.MULTILINE);
|
||||
private final BoundingBox[] blockSections;
|
||||
private final Supplier<Material> block;
|
||||
|
||||
@ -21,10 +22,7 @@ final class ShapeImpl implements Shape {
|
||||
}
|
||||
|
||||
static ShapeImpl parseBlockFromRegistry(String str, Supplier<Material> block) {
|
||||
final String regex = "\\d.\\d{1,3}";
|
||||
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
|
||||
final Matcher matcher = pattern.matcher(str);
|
||||
|
||||
final Matcher matcher = PATTERN.matcher(str);
|
||||
DoubleList vals = new DoubleArrayList();
|
||||
while (matcher.find()) {
|
||||
double newVal = Double.parseDouble(matcher.group());
|
||||
|
Loading…
Reference in New Issue
Block a user