This is an automated email from the ASF dual-hosted git repository.

okram pushed a commit to branch tp4
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 1c3c607e2df1531606494cb0dd9e19d736569f3c
Author: Marko A. Rodriguez <okramma...@gmail.com>
AuthorDate: Tue Mar 12 12:25:09 2019 -0600

    have a much cleaner implementation of RepeatBranch. Simplified Compilation 
a bit.
---
 .../tinkerpop/machine/bytecode/Compilation.java      |  5 -----
 .../machine/functions/branch/RepeatBranch.java       | 20 +++++++++-----------
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git 
a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java
 
b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java
index a3d9b6c..f973a8f 100644
--- 
a/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java
+++ 
b/java/core/src/main/java/org/apache/tinkerpop/machine/bytecode/Compilation.java
@@ -55,11 +55,6 @@ public final class Compilation<C, S, E> implements 
Serializable {
         return this.processor;
     }
 
-    public void addTraverser(final Traverser<C, S> traverser) {
-        this.prepareProcessor();
-        this.processor.addStart(traverser);
-    }
-
     public void reset() {
         if (null != this.processor)
             this.processor.reset();
diff --git 
a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java
 
b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java
index c879373..f8ec403 100644
--- 
a/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java
+++ 
b/java/core/src/main/java/org/apache/tinkerpop/machine/functions/branch/RepeatBranch.java
@@ -23,9 +23,9 @@ import org.apache.tinkerpop.machine.coefficients.Coefficient;
 import org.apache.tinkerpop.machine.functions.AbstractFunction;
 import org.apache.tinkerpop.machine.functions.BranchFunction;
 import org.apache.tinkerpop.machine.traversers.Traverser;
+import org.apache.tinkerpop.util.IteratorUtils;
 import org.apache.tinkerpop.util.StringFactory;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
@@ -47,17 +47,15 @@ public class RepeatBranch<C, S> extends AbstractFunction<C, 
S, Iterator<Traverse
 
     @Override
     public Iterator<Traverser<C, S>> apply(final Traverser<C, S> traverser) {
-        this.repeat.addTraverser(traverser);
-        final List<Traverser<C, S>> toGo = new ArrayList<>();
-        while (this.repeat.getProcessor().hasNext()) {
-            Traverser<C, S> t = this.repeat.getProcessor().next();
-            boolean loop = !this.until.filterTraverser(t);
-            if (loop)
+        this.repeat.getProcessor().addStart(traverser);
+        return IteratorUtils.filter(this.repeat.getProcessor(), t -> {
+            if (!this.until.filterTraverser(t)) {
                 this.repeat.getProcessor().addStart(t);
-            else
-                toGo.add(t);
-        }
-        return toGo.iterator();
+                return false;
+            } else
+                return true;
+
+        });
     }
 
     @Override

Reply via email to