Skip to content

Commit

Permalink
optimize map
Browse files Browse the repository at this point in the history
  • Loading branch information
taoguan committed Nov 28, 2023
1 parent 0c0541c commit 776314f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* Helper class to coerce values from Java to lua within the luajava library.
Expand Down Expand Up @@ -109,7 +110,7 @@ public LuaValue coerce( Object javaValue ) {
}


static final Map COERCIONS = Collections.synchronizedMap(new HashMap());
static final Map COERCIONS = new ConcurrentHashMap();

static {
Coercion boolCoercion = new BoolCoercion() ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* Helper class to coerce values from lua to Java within the luajava library.
Expand Down Expand Up @@ -55,7 +56,7 @@ public static Object coerce(io.github.taoguan.luaj.LuaValue value, Class clazz)
return getCoercion(clazz).coerce(value);
}

static final Map COERCIONS = Collections.synchronizedMap(new HashMap());
static final Map COERCIONS = new ConcurrentHashMap();

static final class BoolCoercion implements Coercion {
public String toString() {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/github/taoguan/luaj/lib/jse/JavaMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* LuaValue that represents a Java method.
Expand All @@ -22,7 +23,7 @@
*/
public class JavaMethod extends JavaMember {

static final Map<Method, JavaMethod> methods = Collections.synchronizedMap(new HashMap());
static final Map<Method, JavaMethod> methods = new ConcurrentHashMap();

static JavaMethod forMethod(Method m) {
JavaMethod j = methods.get(m);
Expand Down

0 comments on commit 776314f

Please sign in to comment.