You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2017/03/10 18:27:29 UTC

tinkerpop git commit: TINKERPOP-1642 Minor refactoring to get rid of duplicate code

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1642 103d7f9df -> 249a5d36e


TINKERPOP-1642 Minor refactoring to get rid of duplicate code


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

Branch: refs/heads/TINKERPOP-1642
Commit: 249a5d36ea2e29f26c6495e1130b2f0661133985
Parents: 103d7f9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Mar 10 13:27:01 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Mar 10 13:27:01 2017 -0500

----------------------------------------------------------------------
 .../process/traversal/util/TraversalHelper.java  | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/249a5d36/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
index 5163824..95862d0 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
@@ -417,7 +417,7 @@ public final class TraversalHelper {
      * Determine if any step in {@link Traversal} or its children match the step given the provided {@link Predicate}.
      *
      * @param predicate the match function
-     * @param traversal th traversal to perform the action on
+     * @param traversal the traversal to perform the action on
      * @return {@code true} if there is a match and {@code false} otherwise
      */
     public static boolean anyStepRecursively(final Predicate<Step> predicate, final Traversal.Admin<?, ?> traversal) {
@@ -425,18 +425,19 @@ public final class TraversalHelper {
             if (predicate.test(step)) {
                 return true;
             }
-            if (step instanceof TraversalParent) {
-                for (final Traversal.Admin<?, ?> localChild : ((TraversalParent) step).getLocalChildren()) {
-                    if (anyStepRecursively(predicate, localChild)) return true;
-                }
-                for (final Traversal.Admin<?, ?> globalChild : ((TraversalParent) step).getGlobalChildren()) {
-                    if (anyStepRecursively(predicate, globalChild)) return true;
-                }
-            }
+
+            if (step instanceof TraversalParent) anyStepRecursively(predicate, ((TraversalParent) step));
         }
         return false;
     }
 
+    /**
+     * Determine if any child step of a {@link TraversalParent} match the step given the provided {@link Predicate}.
+     *
+     * @param predicate the match function
+     * @param step the step to perform the action on
+     * @return {@code true} if there is a match and {@code false} otherwise
+     */
     public static boolean anyStepRecursively(final Predicate<Step> predicate, final TraversalParent step) {
         for (final Traversal.Admin<?, ?> localChild : step.getLocalChildren()) {
             if (anyStepRecursively(predicate, localChild)) return true;