FelixGV commented on PR #8464: URL: https://github.com/apache/pinot/pull/8464#issuecomment-1087952792
Would it not be more optimal to return just `Collections.singletonList(e)` rather than wrapping the one element in an `ArrayList`? Memory-wise, the singleton list should have less memory overhead since it doesn't carry an array. The singleton list, however, is immutable, and will throw `UnsupportedOperationException` if you try to add more items into it, which may be either good or bad, depending on the use case. If an immutable single element list is what you're looking for, then I would think singletonList is ideal. Moreover, in cases where you're passing a constant into the list (e.g. when you're passing `"*"` or `ExpressionContext.forIdentifier("*")`) then you could allocate that statically and keep reusing the same instance, which could be even more efficient. The above may or may not make sense in this context, so take it with a grain of salt. I am always curious about performance-related work in other projects, to see if I can leverage them elsewhere, which is why I looked at this PR (: ... -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org