Repository: tinkerpop
Updated Branches:
  refs/heads/master 116d743f2 -> 6e0ccd836


Minor code refactoring in JavaTranslator CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f02f94fd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f02f94fd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f02f94fd

Branch: refs/heads/master
Commit: f02f94fd067799e5f532086a762c35abd3a11a93
Parents: b25b976
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Mar 13 08:40:10 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Mar 13 08:40:10 2018 -0400

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/jsr223/JavaTranslator.java   | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f02f94fd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
index df12055..3e0e6da 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/JavaTranslator.java
@@ -190,7 +190,7 @@ public final class JavaTranslator<S extends 
TraversalSource, T extends Traversal
         }
     }
 
-    private Object invokeMethod(final Object delegate, final Class returnType, 
final String methodName, final Object... arguments) {
+    private Object invokeMethod(final Object delegate, final Class<?> 
returnType, final String methodName, final Object... arguments) {
         // populate method cache for fast access to methods in subsequent calls
         final Map<String, List<Method>> methodCache = 
GLOBAL_METHOD_CACHE.getOrDefault(delegate.getClass(), new HashMap<>());
         if (methodCache.isEmpty()) buildMethodCache(delegate, methodCache);
@@ -222,7 +222,7 @@ public final class JavaTranslator<S extends 
TraversalSource, T extends Traversal
                                     found = false;
                                     break;
                                 }
-                                Object[] varArgs = (Object[]) 
Array.newInstance(parameterClass, argumentsCopy.length - i);
+                                final Object[] varArgs = (Object[]) 
Array.newInstance(parameterClass, argumentsCopy.length - i);
                                 int counter = 0;
                                 for (int j = i; j < argumentsCopy.length; j++) 
{
                                     varArgs[counter++] = argumentsCopy[j];
@@ -263,11 +263,7 @@ public final class JavaTranslator<S extends 
TraversalSource, T extends Traversal
         if (methodCache.isEmpty()) {
             for (final Method method : delegate.getClass().getMethods()) {
                 if (!(method.getName().equals("addV") && 
method.getParameterCount() == 1 && 
method.getParameters()[0].getType().equals(Object[].class))) { // hack cause 
its hard to tell Object[] vs. String :|
-                    List<Method> list = methodCache.get(method.getName());
-                    if (null == list) {
-                        list = new ArrayList<>();
-                        methodCache.put(method.getName(), list);
-                    }
+                    final List<Method> list = 
methodCache.computeIfAbsent(method.getName(), k -> new ArrayList<>());
                     list.add(method);
                 }
             }

Reply via email to