[No QA] Improve performance of isFilterSupported#83241
Conversation
- Add ALLOWED_TYPE_FILTERS_SET built once at module load from ALLOWED_TYPE_FILTERS - Add REPORT_FIELD_FILTER_KEY and REPORT_FIELD_GLOBAL_PREFIX constants - Replace array.some() with Set.has() and single report-field prefix check - Keeps behavior identical; improves performance when called in loops (SearchFiltersBar, buildQueryStringFromFilterFormValues) Co-authored-by: Cursor <cursoragent@cursor.com>
- Change each type's value from array to new Set([...]) - Add Record<string, Set<string>> type for O(1) lookups at source Co-authored-by: Cursor <cursoragent@cursor.com>
- Remove ALLOWED_TYPE_FILTERS_SET and module-level loop - Use imported ALLOWED_TYPE_FILTERS[type] (now Sets) for .has() lookups Co-authored-by: Cursor <cursoragent@cursor.com>
isFilterSupportedisFilterSupported
|
@QichenZhu Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@sobitneupane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
Reviewer Checklist
|
|
🚧 @JS00001 has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/JS00001 in version: 9.3.26-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.3.26-8 🚀
|
Explanation of Change
Uses a set to reduce the O(n) lookup to O(1). Additionally, returns early if we find a match to avoid the
String.startsWithcall.Fixed Issues
$ #83239
Tests
Offline tests
N/A
QA Steps
N/A
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari