mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-27 21:29:47 +01:00
Optimize VerboseHandler by delaying construction of stack trace array until later
This commit is contained in:
parent
8cecfe5b7c
commit
83e9ac04b2
@ -80,7 +80,7 @@ public class VerboseHandler implements AutoCloseable {
|
||||
return;
|
||||
}
|
||||
|
||||
StackTraceElement[] trace = new Exception().getStackTrace();
|
||||
Throwable trace = new Throwable();
|
||||
String thread = Thread.currentThread().getName();
|
||||
|
||||
// add the check data to a queue to be processed later.
|
||||
@ -105,7 +105,7 @@ public class VerboseHandler implements AutoCloseable {
|
||||
return;
|
||||
}
|
||||
|
||||
StackTraceElement[] trace = new Exception().getStackTrace();
|
||||
Throwable trace = new Throwable();
|
||||
String thread = Thread.currentThread().getName();
|
||||
|
||||
// add the check data to a queue to be processed later.
|
||||
|
@ -46,7 +46,7 @@ public class MetaCheckEvent extends VerboseEvent {
|
||||
*/
|
||||
private final String result;
|
||||
|
||||
public MetaCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, StackTraceElement[] checkTrace, String checkThread, String key, String result) {
|
||||
public MetaCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, Throwable checkTrace, String checkThread, String key, String result) {
|
||||
super(checkTarget, checkQueryOptions, checkTrace, checkThread);
|
||||
this.origin = origin;
|
||||
this.key = key;
|
||||
|
@ -47,7 +47,7 @@ public class PermissionCheckEvent extends VerboseEvent {
|
||||
*/
|
||||
private final TristateResult result;
|
||||
|
||||
public PermissionCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, StackTraceElement[] checkTrace, String checkThread, String permission, TristateResult result) {
|
||||
public PermissionCheckEvent(Origin origin, String checkTarget, QueryOptions checkQueryOptions, Throwable checkTrace, String checkThread, String permission, TristateResult result) {
|
||||
super(checkTarget, checkQueryOptions, checkTrace, checkThread);
|
||||
this.origin = origin;
|
||||
this.permission = permission;
|
||||
|
@ -54,16 +54,16 @@ public abstract class VerboseEvent implements VariableEvaluator {
|
||||
private final QueryOptions checkQueryOptions;
|
||||
|
||||
/**
|
||||
* The stack trace when the check took place
|
||||
* The throwable created when the check took place
|
||||
*/
|
||||
private final StackTraceElement[] checkTrace;
|
||||
private final Throwable checkTrace;
|
||||
|
||||
/**
|
||||
* The name of the thread where the check took place
|
||||
*/
|
||||
private final String checkThread;
|
||||
|
||||
protected VerboseEvent(String checkTarget, QueryOptions checkQueryOptions, StackTraceElement[] checkTrace, String checkThread) {
|
||||
protected VerboseEvent(String checkTarget, QueryOptions checkQueryOptions, Throwable checkTrace, String checkThread) {
|
||||
this.checkTarget = checkTarget;
|
||||
this.checkQueryOptions = checkQueryOptions;
|
||||
this.checkTrace = checkTrace;
|
||||
@ -79,7 +79,7 @@ public abstract class VerboseEvent implements VariableEvaluator {
|
||||
}
|
||||
|
||||
public StackTraceElement[] getCheckTrace() {
|
||||
return this.checkTrace;
|
||||
return this.checkTrace.getStackTrace();
|
||||
}
|
||||
|
||||
public String getCheckThread() {
|
||||
@ -107,7 +107,7 @@ public abstract class VerboseEvent implements VariableEvaluator {
|
||||
})
|
||||
.add("trace", new JArray()
|
||||
.consume(arr -> {
|
||||
int overflow = tracePrinter.process(this.checkTrace, StackTracePrinter.elementToString(arr::add));
|
||||
int overflow = tracePrinter.process(getCheckTrace(), StackTracePrinter.elementToString(arr::add));
|
||||
if (overflow != 0) {
|
||||
arr.add("... and " + overflow + " more");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user