rj00a / evenio

An event-driven Entity Component System
MIT License
132 stars 14 forks source link

add `.len()` directly to `Fetcher` instead of needing to do `.iter().len()` #64

Closed andrewgazelka closed 3 months ago

andrewgazelka commented 3 months ago

thoughts?

Pro: Easier to call .len()

Con: it could be bad if people expect it to be a simple memory lookup...

rj00a commented 3 months ago

Since it's not O(1) I think it could cause some surprises. Are you using .iter().len() frequently?

andrewgazelka commented 3 months ago

Since it's not O(1) I think it could cause some surprises. Are you using .iter().len() frequently?

I was mostly using it to allocate a Vec with that len in a custom allocator because there is no collect_in unfortunately

edit: collect_into exists; I do not believe this alias should be added anymore (at least without further reason).