feat: Re-use a NOOP tracer

This commit is contained in:
Riley Park 2021-05-28 06:56:42 -07:00
parent d7d0c0fa93
commit f400b1ff15
No known key found for this signature in database
GPG Key ID: D831AF236C834E45

View File

@ -27,7 +27,7 @@ import java.util.stream.Stream;
public abstract class LifecycleTracer {
public static LifecycleTracer get() {
if (Trace.TRACE_LIFECYCLE_DEPTH == 0) {
return new NoOpTracer();
return NoOpTracer.INSTANCE;
}
StackTracer stackTracer = new StackTracer();
stackTracer.addTrace(StackTracer.WALKER.walk(new Trace("allocate", 0)));
@ -45,6 +45,8 @@ public abstract class LifecycleTracer {
public abstract <E extends Throwable> E attachTrace(E throwable);
private static final class NoOpTracer extends LifecycleTracer {
private static final NoOpTracer INSTANCE = new NoOpTracer();
@Override
public void acquire(int acquires) {
}