Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuse the iterator in LazyBuffer #727

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

Philippe-Cholet
Copy link
Member

@Philippe-Cholet Philippe-Cholet commented Aug 15, 2023

Fuse the iterator in LazyBuffer.
@phimuemue Do I push the new LazyBuffer::size_hint here?

Copy link
Member

@phimuemue phimuemue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Philippe-Cholet! Thanks a lot for your engagement.

Having this as a separate PR simplifies review a lot. Could you shed some light on my question regarding the Powerset::size_hint? I'd merge this if you agree with both.

pub(crate) fn src(&self) -> &I { &self.pool.it }
pub(crate) fn src(&self) -> &Fuse<I> { &self.pool.it }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is only used in Powerset::size_hint, where we ask for src().size_hint - I think that using the size_hint of the fused iterator is actually what we want there. Can you confirm this?

I guess that Powerset::size_hint should - in the future - also redirect to LazyBuffer::size_hint, no? Then we could get rid of this src exposing the innards of LazyBuffer entirely

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes entirely, I confirm that Powerset::size_hint wants the not yet written LazyBuffer::size_hint from the wrapped Combinations.
fn src might become fn pool(&self) -> &LazyBuffer<I> later in order for Powerset::size_hint to let src_total = self.combs.pool().size_hint(); instead of doing the job of LazyBuffer::size_hint.

@phimuemue
Copy link
Member

Super, thanks.

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 16, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

  • bors build finished

@bors bors bot merged commit 64f6fb5 into rust-itertools:master Aug 16, 2023
@Philippe-Cholet Philippe-Cholet deleted the lazy_buffer_size_hint branch August 16, 2023 10:30
@jswrenn jswrenn added this to the next milestone Nov 14, 2023
@jswrenn jswrenn mentioned this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants