From c1b3e34eb76128d2f13e984e3ea6aad004327d17 Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Sat, 4 Apr 2020 21:32:34 +0200 Subject: [PATCH] remove the static constructor because it will inlined else --- .../jwebassembly/module/StringManager.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/de/inetsoftware/jwebassembly/module/StringManager.java b/src/de/inetsoftware/jwebassembly/module/StringManager.java index 6d84cd4..34f23e8 100644 --- a/src/de/inetsoftware/jwebassembly/module/StringManager.java +++ b/src/de/inetsoftware/jwebassembly/module/StringManager.java @@ -35,17 +35,11 @@ import de.inetsoftware.jwebassembly.wasm.ValueType; */ public class StringManager extends LinkedHashMap { - /** - * Signature of method stringConstant. - * - * @see #stringConstant(int) - */ - private static final FunctionName STRING_CONSTANT_FUNCTION = - new FunctionName( "de/inetsoftware/jwebassembly/module/StringManager.stringConstant(I)Ljava/lang/String;" ); + private FunctionName stringConstantFunction; - private FunctionManager functions; + private FunctionManager functions; - private int stringMemoryOffset = -1; + private int stringMemoryOffset; /** * Create a new instance. @@ -80,9 +74,9 @@ public class StringManager extends LinkedHashMap { */ @Nonnull FunctionName getStringConstantFunction() { - if( stringMemoryOffset < 0 ) { + if( stringConstantFunction == null ) { + stringConstantFunction = new FunctionName( "de/inetsoftware/jwebassembly/module/StringManager.stringConstant(I)Ljava/lang/String;" ); // register the function stringsMemoryOffset() as synthetic function - stringMemoryOffset = 0; WatCodeSyntheticFunctionName offsetFunction = new WatCodeSyntheticFunctionName( "de/inetsoftware/jwebassembly/module/StringManager", "stringsMemoryOffset", "()I", "", null, ValueType.i32 ) { protected String getCode() { @@ -90,10 +84,10 @@ public class StringManager extends LinkedHashMap { } }; functions.markAsNeededAndReplaceIfExists( offsetFunction ); - functions.markAsNeeded( STRING_CONSTANT_FUNCTION ); + functions.markAsNeeded( stringConstantFunction ); } - return STRING_CONSTANT_FUNCTION; + return stringConstantFunction; } /**