andreachild commented on code in PR #2919:
URL: https://github.com/apache/tinkerpop/pull/2919#discussion_r1864000319


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GraphStep.java:
##########
@@ -64,11 +68,40 @@ public class GraphStep<S, E extends Element> extends 
AbstractStep<S, E> implemen
     public GraphStep(final Traversal.Admin traversal, final Class<E> 
returnClass, final boolean isStart, final Object... ids) {
         super(traversal);
         this.returnClass = returnClass;
-        this.ids = (ids != null && ids.length == 1 && ids[0] instanceof 
Collection) ? ((Collection) ids[0]).toArray(new Object[((Collection) 
ids[0]).size()]) : ids;
+
+        // if ids is a single collection like g.V(['a','b','c']), then unroll 
it into an array of ids
+        this.ids = 
GValue.ensureGValues(tryUnrollSingleCollectionArgument(ids));
+
         this.isStart = isStart;
+
         this.iteratorSupplier = () -> (Iterator<E>) 
(Vertex.class.isAssignableFrom(this.returnClass) ?
-                this.getTraversal().getGraph().get().vertices(this.ids) :
-                this.getTraversal().getGraph().get().edges(this.ids));
+                
this.getTraversal().getGraph().get().vertices(GValue.resolveToValues(this.ids)) 
:

Review Comment:
   Nit: extract to variable to avoid looping over the `ids` twice:
   
   ```
   Object[] idValues = GValue.resolveToValues(this.ids);
           this.iteratorSupplier = () -> (Iterator<E>) 
(Vertex.class.isAssignableFrom(this.returnClass) ?
                   this.getTraversal().getGraph().get().vertices(idValues) :
                   this.getTraversal().getGraph().get().edges(idValues));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to