-
Notifications
You must be signed in to change notification settings - Fork 3.5k
perf: use lookup maps and for-in loops for faster data access #80660
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
Conversation
|
@mjasikowski 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] |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
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.
|
1c02613 to
f58ff46
Compare
|
@TMisiukiewicz inspired by your changes |
|
Code looks good |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb SafariMacOS: Chrome / Safariweb.mov |
TMisiukiewicz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
✋ 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/mjasikowski in version: 9.3.11-16 🚀
|
Explanation of Change
This PR applies the same performance optimization patterns from PR #80487 to other similar code paths in the codebase. The key optimizations are:
.find()inside loops (O(n*m) complexity)for...inloops instead of chained array methods (Object.entries().filter()) that create intermediate arraysChanges made:
ReportActionsUtils.tsgetMemberChangeMessageElements.find()in.map()ReportActionsUtils.tsgetNotAddedRoomMemberErrorMessageSearchUIUtils.tsgetViolationsObject.fromEntries(Object.entries().filter())with singlefor...inloopReportUtils.tsbuildOptimisticOnboardingDatagetPersonalDetailByEmail()O(1) cache lookup instead ofObject.values().find()OptionsListUtils.tsgetManagerMcTestParticipantgetPersonalDetailByEmail()O(1) cache lookup when using global personal detailsThese optimizations reduce time complexity from O(n*m) to O(n) in hot code paths, similar to the improvements seen in PR #80487
Fixed Issues
$ #80469
PROPOSAL: N/A - Performance improvement follow-up
Tests
npm test -- --testPathPattern="PersonalDetailsUtilsTest"npm test -- --testPathPattern="SearchUIUtilsTest"npm test -- --testPathPattern="OptionsListUtilsTest"Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand 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