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);
|
||||
|
||||
// Initialize classes, get dependency vector and add to 'subsystemsMutable'
|
||||
Object initializedClassRaw;
|
||||
SubsystemClass initializedClass;
|
||||
for (Class<?> clazz : annotatedClasses) {
|
||||
try {
|
||||
// Create new instance
|
||||
Object initializedClassRaw = clazz.getDeclaredConstructor().newInstance();
|
||||
SubsystemClass initializedClass = null;
|
||||
initializedClassRaw = clazz.getDeclaredConstructor().newInstance();
|
||||
initializedClass = null;
|
||||
|
||||
// Check if class implements SubsystemMainClass
|
||||
if (initializedClassRaw instanceof SubsystemClass subsystemInstance)
|
||||
initializedClass = subsystemInstance;
|
||||
if (initializedClassRaw instanceof SubsystemClass)
|
||||
initializedClass = (SubsystemClass) initializedClassRaw;
|
||||
else
|
||||
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 fork = null;
|
||||
|
||||
// Iterate through all chraracters
|
||||
// Iterate through all characters
|
||||
for (Character character : versionString.toCharArray()) {
|
||||
switch (parsingId) {
|
||||
case 0 -> { // 'v' character
|
||||
|
|
|
@ -44,7 +44,8 @@ public final class JvmArguments implements Placeholder {
|
|||
StringBuilder arguments = new StringBuilder();
|
||||
|
||||
for (String argument : JvmInformation.getArguments()) {
|
||||
if (!arguments.isEmpty()) arguments.append(" ");
|
||||
if (!arguments.isEmpty())
|
||||
arguments.append(" ");
|
||||
|
||||
arguments
|
||||
.append("\"")
|
||||
|
|
|
@ -158,17 +158,23 @@ public final class DependencyResolver {
|
|||
|
||||
// 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()) {
|
||||
// 0 = identifier
|
||||
// 1 = version equal
|
||||
// 2 = version smaller
|
||||
// 3 = version bigger
|
||||
int mode = 0;
|
||||
boolean[] duplicateCheck = new boolean[3];
|
||||
StringBuilder identifier = new StringBuilder();
|
||||
StringBuilder versionEqual = new StringBuilder();
|
||||
StringBuilder versionSmaller = new StringBuilder();
|
||||
StringBuilder versionBigger = new StringBuilder();
|
||||
mode = 0;
|
||||
duplicateCheck = new boolean[3];
|
||||
identifier = new StringBuilder();
|
||||
versionEqual = new StringBuilder();
|
||||
versionSmaller = new StringBuilder();
|
||||
versionBigger = new StringBuilder();
|
||||
|
||||
// Get variables
|
||||
for (char character : dependency.toCharArray()) {
|
||||
|
|
|
@ -126,6 +126,7 @@ public final class Miscellaneous {
|
|||
for (String separator : separators)
|
||||
if (countOccurrences(string, separator) == requiredOccurrences)
|
||||
return separator;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -142,6 +143,7 @@ public final class Miscellaneous {
|
|||
for (String separator : separators)
|
||||
if (countOccurrences(string, separator) >= minimumOccurrences)
|
||||
return separator;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,9 @@ public class UnitLogger {
|
|||
levelName = "TEST";
|
||||
|
||||
StringBuilder args = new StringBuilder();
|
||||
boolean stringQuotes;
|
||||
for (Object arg : additionalStuff) {
|
||||
boolean stringQuotes = arg instanceof String;
|
||||
stringQuotes = arg instanceof String;
|
||||
|
||||
// Print full class path for enums
|
||||
if (arg instanceof Enum<?>) {
|
||||
|
|
Loading…
Reference in a new issue