forked from StarOpenSource/Engine
Prevent allocation in loops
This commit is contained in:
parent
ad7b3568cf
commit
ca3bf94a48
6 changed files with 29 additions and 17 deletions
|
@ -325,15 +325,17 @@ public final class Engine extends SubsystemClass {
|
||||||
Set<@NotNull Class<?>> annotatedClasses = reflections.getTypesAnnotatedWith(EngineSubsystem.class);
|
Set<@NotNull Class<?>> annotatedClasses = reflections.getTypesAnnotatedWith(EngineSubsystem.class);
|
||||||
|
|
||||||
// Initialize classes, get dependency vector and add to 'subsystemsMutable'
|
// Initialize classes, get dependency vector and add to 'subsystemsMutable'
|
||||||
|
Object initializedClassRaw;
|
||||||
|
SubsystemClass initializedClass;
|
||||||
for (Class<?> clazz : annotatedClasses) {
|
for (Class<?> clazz : annotatedClasses) {
|
||||||
try {
|
try {
|
||||||
// Create new instance
|
// Create new instance
|
||||||
Object initializedClassRaw = clazz.getDeclaredConstructor().newInstance();
|
initializedClassRaw = clazz.getDeclaredConstructor().newInstance();
|
||||||
SubsystemClass initializedClass = null;
|
initializedClass = null;
|
||||||
|
|
||||||
// Check if class implements SubsystemMainClass
|
// Check if class implements SubsystemMainClass
|
||||||
if (initializedClassRaw instanceof SubsystemClass subsystemInstance)
|
if (initializedClassRaw instanceof SubsystemClass)
|
||||||
initializedClass = subsystemInstance;
|
initializedClass = (SubsystemClass) initializedClassRaw;
|
||||||
else
|
else
|
||||||
logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Does not implement " + SubsystemClass.class.getName());
|
logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Does not implement " + SubsystemClass.class.getName());
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ public final class StarOpenSourceVersioningSystem implements VersioningSystem {
|
||||||
String companion = null;
|
String companion = null;
|
||||||
String fork = null;
|
String fork = null;
|
||||||
|
|
||||||
// Iterate through all chraracters
|
// Iterate through all characters
|
||||||
for (Character character : versionString.toCharArray()) {
|
for (Character character : versionString.toCharArray()) {
|
||||||
switch (parsingId) {
|
switch (parsingId) {
|
||||||
case 0 -> { // 'v' character
|
case 0 -> { // 'v' character
|
||||||
|
|
|
@ -44,7 +44,8 @@ public final class JvmArguments implements Placeholder {
|
||||||
StringBuilder arguments = new StringBuilder();
|
StringBuilder arguments = new StringBuilder();
|
||||||
|
|
||||||
for (String argument : JvmInformation.getArguments()) {
|
for (String argument : JvmInformation.getArguments()) {
|
||||||
if (!arguments.isEmpty()) arguments.append(" ");
|
if (!arguments.isEmpty())
|
||||||
|
arguments.append(" ");
|
||||||
|
|
||||||
arguments
|
arguments
|
||||||
.append("\"")
|
.append("\"")
|
||||||
|
|
|
@ -158,17 +158,23 @@ public final class DependencyResolver {
|
||||||
|
|
||||||
// provides
|
// provides
|
||||||
|
|
||||||
|
// 0 = identifier
|
||||||
|
// 1 = version equal
|
||||||
|
// 2 = version smaller
|
||||||
|
// 3 = version bigger
|
||||||
|
int mode;
|
||||||
|
boolean[] duplicateCheck;
|
||||||
|
StringBuilder identifier;
|
||||||
|
StringBuilder versionEqual;
|
||||||
|
StringBuilder versionSmaller;
|
||||||
|
StringBuilder versionBigger;
|
||||||
for (String dependency : vector.getDependencies()) {
|
for (String dependency : vector.getDependencies()) {
|
||||||
// 0 = identifier
|
mode = 0;
|
||||||
// 1 = version equal
|
duplicateCheck = new boolean[3];
|
||||||
// 2 = version smaller
|
identifier = new StringBuilder();
|
||||||
// 3 = version bigger
|
versionEqual = new StringBuilder();
|
||||||
int mode = 0;
|
versionSmaller = new StringBuilder();
|
||||||
boolean[] duplicateCheck = new boolean[3];
|
versionBigger = new StringBuilder();
|
||||||
StringBuilder identifier = new StringBuilder();
|
|
||||||
StringBuilder versionEqual = new StringBuilder();
|
|
||||||
StringBuilder versionSmaller = new StringBuilder();
|
|
||||||
StringBuilder versionBigger = new StringBuilder();
|
|
||||||
|
|
||||||
// Get variables
|
// Get variables
|
||||||
for (char character : dependency.toCharArray()) {
|
for (char character : dependency.toCharArray()) {
|
||||||
|
|
|
@ -126,6 +126,7 @@ public final class Miscellaneous {
|
||||||
for (String separator : separators)
|
for (String separator : separators)
|
||||||
if (countOccurrences(string, separator) == requiredOccurrences)
|
if (countOccurrences(string, separator) == requiredOccurrences)
|
||||||
return separator;
|
return separator;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,6 +143,7 @@ public final class Miscellaneous {
|
||||||
for (String separator : separators)
|
for (String separator : separators)
|
||||||
if (countOccurrences(string, separator) >= minimumOccurrences)
|
if (countOccurrences(string, separator) >= minimumOccurrences)
|
||||||
return separator;
|
return separator;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,9 @@ public class UnitLogger {
|
||||||
levelName = "TEST";
|
levelName = "TEST";
|
||||||
|
|
||||||
StringBuilder args = new StringBuilder();
|
StringBuilder args = new StringBuilder();
|
||||||
|
boolean stringQuotes;
|
||||||
for (Object arg : additionalStuff) {
|
for (Object arg : additionalStuff) {
|
||||||
boolean stringQuotes = arg instanceof String;
|
stringQuotes = arg instanceof String;
|
||||||
|
|
||||||
// Print full class path for enums
|
// Print full class path for enums
|
||||||
if (arg instanceof Enum<?>) {
|
if (arg instanceof Enum<?>) {
|
||||||
|
|
Loading…
Reference in a new issue