8000 Use sequences for lazy evaluation by GeorgCantor · Pull Request #702 · androidx/androidx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use sequences for lazy evaluation #702

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

Open
wants to merge 2 commits into
base: androidx-main
Choose a base branch
from

Conversation

GeorgCantor
Copy link
@GeorgCantor GeorgCantor commented Sep 22, 2024

Proposed Changes

Use of Sequences: By converting the collection to a sequence using asSequence(), we enable lazy evaluation, which can improve performance when dealing with large collections by avoiding unnecessary intermediate collections.

Map Not Null: Instead of filtering and then casting, we use mapNotNull to both filter and cast in one step, making the code cleaner.

Testing

Manually

Issues Fixed

Use sequences for lazy evaluation

Instead of filtering and then casting, we use mapNotNull to both filter and cast in one step, making the code cleaner.
@dlam
Copy link
Member
dlam commented Sep 23, 2024

Drive-by review - I'll defer to @jbw0033 and @ianhanniballake as the owners if they want to override.

In general manually testing is not good enough. Performance improvements should have a microbenchmark that shows the improvement. How much overhead does this add and at what point does it start paying off?

We are also still filtering twice on the key and value separately, and it seems like we should combine that too.

@romainguy
Copy link
Contributor

This begs to become a simple for loop :)

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
0