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


##########
src/java/org/apache/cassandra/cql3/restrictions/SimpleRestriction.java:
##########
@@ -225,17 +226,22 @@ public void restrict(RangeSet<ClusteringElements> 
rangeSet, QueryOptions options
 
     private List<ClusteringElements> bindAndGetClusteringElements(QueryOptions 
options)
     {
+        List<ClusteringElements> elements = new ArrayList<>();

Review Comment:
   @samueldlightfoot if you think about that ... if columnsExpression.kind() 
goes to default case which throws, then you have created an object of an empty 
list unnecessarily. I think what you could do is to make that list directly in 
either TOKEN or MULTI_COLUMN case. That way we would save an object creation 
when it goes to default. 
   
   It would be also interesting to investigate if it is possible (and how 
frequent) that bindAndGet(options) is empty. Then I would probably check if it 
is empty and only if it is not I would create that list. Presumably, if it is 
empty more often than not then checking its size makes sense as I guess that is 
faster / cheaper than object creation.
   
   edit: checking if an array list is empty or not takes just one method 
invocation of isEmpty() and comparing size property of int to 0.



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