smiklosovic commented on code in PR #3348:
URL: https://github.com/apache/cassandra/pull/3348#discussion_r1627385308


##########
src/java/org/apache/cassandra/cql3/restrictions/SimpleRestriction.java:
##########
@@ -229,18 +231,42 @@ private List<ClusteringElements> 
bindAndGetClusteringElements(QueryOptions optio
         {
             case SINGLE_COLUMN:
             case TOKEN:
-                return bindAndGet(options).stream()
-                                          .map(b ->  
ClusteringElements.of(columnsExpression.columnSpecification(), b))
-                                          .collect(Collectors.toList());
+                return bindAndGetSingleTermClusteringElements(options);
             case MULTI_COLUMN:
-                return bindAndGetElements(options).stream()
-                                                  .map(buffers -> 
ClusteringElements.of(columnsExpression.columns(), buffers))
-                                                  
.collect(Collectors.toList());
+                return bindAndGetMultiTermClusteringElements(options);
             default:
                 throw new UnsupportedOperationException();
         }
     }
 
+    private List<ClusteringElements> 
bindAndGetSingleTermClusteringElements(QueryOptions options)
+    {
+        List<ByteBuffer> values = bindAndGet(options);
+        if (!values.isEmpty()) {
+            List<ClusteringElements> elements = new ArrayList<>(values.size());
+            for (ByteBuffer value : values) {
+                ClusteringElements byteBuffers = 
ClusteringElements.of(columnsExpression.columnSpecification(), value);
+                elements.add(byteBuffers);

Review Comment:
   you could omit byteBuffers variable by putting the result of 
ClusteringElements.off directly to elements.add
   
   By doing so, you will have a for loop consisting of one line of the code in 
its body., In that case you can omit braces for `for` entirely. 



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to