smiklosovic commented on code in PR #4785:
URL: https://github.com/apache/cassandra/pull/4785#discussion_r3187300059
##########
src/java/org/apache/cassandra/cql3/statements/SelectStatement.java:
##########
@@ -815,11 +814,21 @@ private ReadQuery getSliceCommands(QueryOptions options,
ClientState state, Colu
if (filter == null || filter.isEmpty(table.comparator))
return ReadQuery.empty(table);
- List<DecoratedKey> decoratedKeys = new ArrayList<>(keys.size());
- for (ByteBuffer key : keys)
+ List<DecoratedKey> decoratedKeys;
+ if (keys.size() == 1) // reduce allocations in collections for keys
{
+ ByteBuffer key = keys.get(0);
QueryProcessor.validateKey(key);
-
decoratedKeys.add(table.partitioner.decorateKey(ByteBufferUtil.clone(key)));
+ decoratedKeys =
Collections.singletonList(table.partitioner.decorateKey(key));
+ }
+ else
+ {
+ decoratedKeys = new ArrayList<>(keys.size());
+ for (ByteBuffer key : keys)
+ {
+ QueryProcessor.validateKey(key);
Review Comment:
actually, the resizing is done automatically when `new ArrayList<>()` is
used, no?
--
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]