Page MenuHomePhabricator

[web][native] Refactor getDefaultTextMessageRules
AbandonedPublic

Authored by patryk on Aug 19 2023, 3:38 AM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 9 2024, 9:40 AM
Unknown Object (File)
Oct 27 2024, 2:57 PM
Unknown Object (File)
Oct 27 2024, 2:57 PM
Unknown Object (File)
Oct 27 2024, 2:57 PM
Unknown Object (File)
Oct 27 2024, 2:49 PM
Unknown Object (File)
Oct 12 2024, 8:29 PM
Unknown Object (File)
Sep 27 2024, 8:49 PM
Unknown Object (File)
Sep 10 2024, 3:26 AM
Subscribers

Details

Reviewers
tomek
inka
rohan
Summary

This diff refactors getDefaultTextMessageRules function in rules.react.js on web and native. Rather than storing defaultTextMessageRules in a variable, _memoize can be used.

Depends on D8873.

Test Plan

Tested later in the stack.

Diff Detail

Repository
rCOMM Comm
Branch
arcpatch-D8871
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

patryk held this revision as a draft.

Merge Refactor getDefaultTextMessageRules diff on web

patryk retitled this revision from [native] Refactor getDefaultTextMessageRules to [web][native] Refactor getDefaultTextMessageRules.Aug 19 2023, 4:22 AM
patryk edited the test plan for this revision. (Show Details)
patryk added reviewers: tomek, inka, rohan.

What's the point of this change? I'm not sure that this code is better than the original... it requires understanding _memoize, and the original code seemed clear enough.

_memoize makes sense to use when we need to memoize multiple different calculations. In this case, we only need to cache one thing at a time, so I'm not sure it's useful.

I could see an argument that we already need to understand _memoize to understand this file. But my intuition is that this diff doesn't really result in any meaningful improvements. Curious for other reviewers' takes.

My primary motivation for this diff was to align with the rules.react.js style. We use _memoize for almost all variables/functions defined in this file. I felt that storing getDefaultTextMessageRules in a variable, instead of following this file convention, was making this piece of code somewhat outdated. While using _memoize might not lead to significant improvements, it does, in my opinion, present a better aesthetic. However, I'm open to other reviewers' perspectives and suggestions.

This revision is now accepted and ready to land.Aug 28 2023, 3:28 AM

Although this change on its own doesn't have important disadvantages, the following diff D8846 makes it worse. The consequence is that we're wasting memory because _memoize remembers the result of each computation, while we only care about the most recent one. So it's better to reintroduce the previous approach.

Since _memoize can use too much memory, I'm abandoning this diff and leaving the previous approach.