Conversation
Replaces the use of `Stream.concat(...).filter(...).collect(...)` in `StatusListFragment.onRemoveAccountPostsEvent` and `NotificationsListFragment.onRemoveAccountPostsEvent` with standard `for` loops and `ArrayList`. This optimization avoids the overhead of Stream object creation and lambda capturing during UI event handling, reducing GC pressure and adhering to the project's strategy of minimizing Stream allocations in hot paths. Co-authored-by: dlukt <201112286+dlukt@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce UI-thread allocations by replacing Java Stream pipelines with explicit loops when handling RemoveAccountPostsEvent in timeline and notifications fragments.
Changes:
- Replaced
Stream.concat(...).filter(...).collect(...)withforloops inStatusListFragment#onRemoveAccountPostsEvent. - Replaced
Stream.concat(...).filter(...).collect(...)withforloops inNotificationsListFragment#onRemoveAccountPostsEvent.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| mastodon/src/main/java/de/icod/techidon/fragments/StatusListFragment.java | Removes Stream-based filtering/collection during account-post removal handling. |
| mastodon/src/main/java/de/icod/techidon/fragments/NotificationsListFragment.java | Removes Stream-based filtering/collection during account-post removal handling for notifications. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mastodon/src/main/java/de/icod/techidon/fragments/StatusListFragment.java
Outdated
Show resolved
Hide resolved
mastodon/src/main/java/de/icod/techidon/fragments/StatusListFragment.java
Outdated
Show resolved
Hide resolved
| // Optimization: Use loops instead of Streams to avoid allocation overhead during event handling. | ||
| List<Notification> toRemove = new ArrayList<>(); | ||
| for (Notification n : data) { | ||
| if (n.account != null && n.account.id.equals(ev.postsByAccountID)) { |
There was a problem hiding this comment.
Stream/Collectors were removed from this method, and there are no remaining usages in this file, but the imports still exist. Java treats unused imports as compilation errors—please delete the java.util.stream.Stream and java.util.stream.Collectors imports (and any related unused stream imports).
mastodon/src/main/java/de/icod/techidon/fragments/NotificationsListFragment.java
Outdated
Show resolved
Hide resolved
mastodon/src/main/java/de/icod/techidon/fragments/NotificationsListFragment.java
Outdated
Show resolved
Hide resolved
| // Optimization: Use loops instead of Streams to avoid allocation overhead during event handling. | ||
| List<Status> toRemove = new ArrayList<>(); | ||
| for (Status s : data) { | ||
| if (s.account.id.equals(ev.postsByAccountID) || (!ev.isUnfollow && s.reblog!=null && s.reblog.account.id.equals(ev.postsByAccountID))) { |
There was a problem hiding this comment.
Stream/Collectors were removed from this method, and there are no remaining usages in this file, but the imports still exist. Java treats unused imports as compilation errors—please delete the java.util.stream.Stream and java.util.stream.Collectors imports (and any related unused stream imports).
…agment.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…agment.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sListFragment.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sListFragment.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@jules mastodon/src/main/java/de/icod/techidon/fragments/StatusListFragment.java |
Thank you for pointing that out! I've removed the unused |
💡 What: Replaced
Stream.concat().filter().collect()with standardforloops when handlingRemoveAccountPostsEventin bothStatusListFragmentandNotificationsListFragment.🎯 Why: The application of Java Streams in these methods creates unnecessary object allocations (Stream instances, Optionals, lambda closures, and Collectors) on the UI thread when processing
RemoveAccountPostsEvent(e.g. from blocking or muting an account). In an Android environment, particularly within lists/fragments, these allocations contribute to garbage collection churn. While this event may not be as high-frequency asonBindViewHolder, eliminating Stream allocations follows the established architectural pattern to reduce memory pressure.📊 Impact: Eliminates
Streamoverhead during post removal processing. Prevents potential GC-related jank associated with temporary object allocations.🔬 Measurement: Verify that un-following, muting, or blocking a user properly removes their posts from the home timeline and notifications view without throwing any
ConcurrentModificationExceptions. The behavior should be identical to the pre-optimized state but without the hidden Stream allocations.PR created automatically by Jules for task 16029898155976106689 started by @dlukt