covers1624/Quack

[Feature] FastStream ops could benefit from knowing the data source is indexable

Opened this issue · 0 comments

  • reversed would not need to allocate
  • skip and last would not need to iterate (potentially) the entire data source
  • first and only could also benefit by not needing to allocate

We would make any collection stream wrapper, as well as operations which produce a list or array internally, indexable.

A potential performance pitfall would be if first or only used an indexer which caused an entire stream to be collected into an array.

first on reversed should turn into a last call on the underlying, rather than allocating
first on sorted should be equivalent to limit(1) which should be equivalent to max, rather than allocating