⚡ Optimize SettingsContainer filter performance#108
Conversation
* Pre-computes lowercased title and split title/description strings when creating Setting instances instead of computing them inside the filter loop. * Changes the filter loop to iterate once through the list instead of three times, using consecutive `else if` conditionals to bucket matches into separate lists and preserve the sorting order.
|
👋 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. |
⚡ Optimize SettingsContainer filter string allocations
💡 What:
The optimization caches the lowercased titles and split string arrays representing the title words and description words when a
Settinginstance is first created. Thefilterfunction now iterates through the settings exactly once, populating matches into three separate list collections sequentially instead of executing three independentforEachpasses over thelistof settings.🎯 Why:
Previously, the
filter(searchTerm)function was severely unoptimized. With every keystroke in the search field, it would iterate over the complete list of settings three separate times. During each iteration, it continuously executed expensive string operations (lowercase()andsplit(' ')) for every setting. These string operations generated numerous small objects that created garbage collector pressure and latency.📊 Measured Improvement:
Using a dedicated Robolectric test performance baseline processing 10 common search terms sequentially 100 times over:
PR created automatically by Jules for task 5764429429682301740 started by @LeanBitLab