Closed
Description
Methods like ReflectionSupport.findField
currently return a List<Field>
.
Under-the-hood, the utils typically use streams and then copy all the elements into a list to return.
Very often, users of findfield()
only need to iterate once through the returned list of fields (in some of my implementations, I've called stream() or forEach() on the result). Storing the stream of fields in an intermediate List
is unnecessary buffering overhead in those cases.
Deliverables
- A set of methods with a signature like
Stream<Field> findFieldsAsStream()
. - Refactor the existing
List<Field> findFields()
to delegate to its equivalent streaming method and calltoList()
on the stream. - Refactor existing usage in the JUnit 5 codebase where the stream interface would be more appropriate and efficient.
Thoughts?