You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by krlohnes <gi...@git.apache.org> on 2018/02/20 00:49:45 UTC

[GitHub] tinkerpop pull request #715: TINKERPOP-1822: change behaviour of repeat step...

Github user krlohnes commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/715#discussion_r169194905
  
    --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatStep.java ---
    @@ -271,7 +274,17 @@ public RepeatEndStep(final Traversal.Admin traversal) {
             protected Iterator<Traverser.Admin<S>> standardAlgorithm() throws NoSuchElementException {
                 final RepeatStep<S> repeatStep = (RepeatStep<S>) this.getTraversal().getParent();
                 while (true) {
    -                final Traverser.Admin<S> start = this.starts.next();
    +                final Traverser.Admin<S> start;
    +                if (this.starts.hasNext()) {
    +                    start = this.starts.next();
    +                } else {
    +                    start = this.stashedStarts.pop();
    +                }
    +                // to make this step depth first search (DFS), we're stashing the remainder for later
    +                while (this.starts.hasNext()) {
    +                    stashedStarts.add(this.starts.next());
    --- End diff --
    
    I think this should be `push` rather than `add` so you maintain a consistent `stack` behavior for a DFS. 


---