From 82d6f52a26c3bfb55d098fbe8c9abc5ea7f6fd42 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Sun, 1 Sep 2024 17:13:57 +0300 Subject: [PATCH] refactor: make some classes final for performance --- src/java/me/topchetoeu/jscript/runtime/Engine.java | 5 +---- src/java/me/topchetoeu/jscript/runtime/Frame.java | 2 +- src/java/me/topchetoeu/jscript/runtime/values/KeyCache.java | 2 +- .../jscript/runtime/values/functions/CodeFunction.java | 2 +- .../jscript/runtime/values/functions/NativeFunction.java | 2 +- .../jscript/runtime/values/objects/ScopeValue.java | 2 +- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/java/me/topchetoeu/jscript/runtime/Engine.java b/src/java/me/topchetoeu/jscript/runtime/Engine.java index e3ada89..e3cb05e 100644 --- a/src/java/me/topchetoeu/jscript/runtime/Engine.java +++ b/src/java/me/topchetoeu/jscript/runtime/Engine.java @@ -7,7 +7,7 @@ import java.util.function.Supplier; import me.topchetoeu.jscript.runtime.exceptions.InterruptException; -public class Engine implements EventLoop { +public final class Engine implements EventLoop { private static class Task implements Comparable> { public final Supplier runnable; public final CompletableFuture notifier = new CompletableFuture(); @@ -74,7 +74,4 @@ public class Engine implements EventLoop { public boolean isRunning() { return this.thread != null; } - - public Engine() { - } } diff --git a/src/java/me/topchetoeu/jscript/runtime/Frame.java b/src/java/me/topchetoeu/jscript/runtime/Frame.java index 1ccf5bb..4e9fb8c 100644 --- a/src/java/me/topchetoeu/jscript/runtime/Frame.java +++ b/src/java/me/topchetoeu/jscript/runtime/Frame.java @@ -21,7 +21,7 @@ import me.topchetoeu.jscript.runtime.values.functions.CodeFunction; import me.topchetoeu.jscript.runtime.values.objects.ObjectValue; import me.topchetoeu.jscript.runtime.values.objects.ScopeValue; -public class Frame { +public final class Frame { public static final Key KEY = Key.of(); public static enum TryState { diff --git a/src/java/me/topchetoeu/jscript/runtime/values/KeyCache.java b/src/java/me/topchetoeu/jscript/runtime/values/KeyCache.java index c1d4840..f5660ed 100644 --- a/src/java/me/topchetoeu/jscript/runtime/values/KeyCache.java +++ b/src/java/me/topchetoeu/jscript/runtime/values/KeyCache.java @@ -5,7 +5,7 @@ import me.topchetoeu.jscript.runtime.values.primitives.NumberValue; import me.topchetoeu.jscript.runtime.values.primitives.StringValue; import me.topchetoeu.jscript.runtime.values.primitives.SymbolValue; -public class KeyCache { +public final class KeyCache { public final Value value; private Integer intCache; private Double doubleCache; diff --git a/src/java/me/topchetoeu/jscript/runtime/values/functions/CodeFunction.java b/src/java/me/topchetoeu/jscript/runtime/values/functions/CodeFunction.java index d3e9e5c..ca23b3d 100644 --- a/src/java/me/topchetoeu/jscript/runtime/values/functions/CodeFunction.java +++ b/src/java/me/topchetoeu/jscript/runtime/values/functions/CodeFunction.java @@ -5,7 +5,7 @@ import me.topchetoeu.jscript.common.environment.Environment; import me.topchetoeu.jscript.runtime.Frame; import me.topchetoeu.jscript.runtime.values.Value; -public class CodeFunction extends FunctionValue { +public final class CodeFunction extends FunctionValue { public final FunctionBody body; public final Value[][] captures; public Environment env; diff --git a/src/java/me/topchetoeu/jscript/runtime/values/functions/NativeFunction.java b/src/java/me/topchetoeu/jscript/runtime/values/functions/NativeFunction.java index 4615f8d..0ad250a 100644 --- a/src/java/me/topchetoeu/jscript/runtime/values/functions/NativeFunction.java +++ b/src/java/me/topchetoeu/jscript/runtime/values/functions/NativeFunction.java @@ -3,7 +3,7 @@ package me.topchetoeu.jscript.runtime.values.functions; import me.topchetoeu.jscript.common.environment.Environment; import me.topchetoeu.jscript.runtime.values.Value; -public class NativeFunction extends FunctionValue { +public final class NativeFunction extends FunctionValue { public static interface NativeFunctionRunner { Value run(Arguments args); } diff --git a/src/java/me/topchetoeu/jscript/runtime/values/objects/ScopeValue.java b/src/java/me/topchetoeu/jscript/runtime/values/objects/ScopeValue.java index c84a295..a968637 100644 --- a/src/java/me/topchetoeu/jscript/runtime/values/objects/ScopeValue.java +++ b/src/java/me/topchetoeu/jscript/runtime/values/objects/ScopeValue.java @@ -4,7 +4,7 @@ import me.topchetoeu.jscript.common.environment.Environment; import me.topchetoeu.jscript.runtime.values.Value; import me.topchetoeu.jscript.runtime.values.Member.FieldMember; -public class ScopeValue extends ObjectValue { +public final class ScopeValue extends ObjectValue { private class VariableField extends FieldMember { private int i;