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
|
||||||
|
|
||||||
for (String dependency : vector.getDependencies()) {
|
|
||||||
// 0 = identifier
|
// 0 = identifier
|
||||||
// 1 = version equal
|
// 1 = version equal
|
||||||
// 2 = version smaller
|
// 2 = version smaller
|
||||||
// 3 = version bigger
|
// 3 = version bigger
|
||||||
int mode = 0;
|
int mode;
|
||||||
boolean[] duplicateCheck = new boolean[3];
|
boolean[] duplicateCheck;
|
||||||
StringBuilder identifier = new StringBuilder();
|
StringBuilder identifier;
|
||||||
StringBuilder versionEqual = new StringBuilder();
|
StringBuilder versionEqual;
|
||||||
StringBuilder versionSmaller = new StringBuilder();
|
StringBuilder versionSmaller;
|
||||||
StringBuilder versionBigger = new StringBuilder();
|
StringBuilder versionBigger;
|
||||||
|
for (String dependency : vector.getDependencies()) {
|
||||||
|
mode = 0;
|
||||||
|
duplicateCheck = new boolean[3];
|
||||||
|
identifier = new StringBuilder();
|
||||||
|
versionEqual = new StringBuilder();
|
||||||
|
versionSmaller = new 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