Page MenuHomePhabricator

[lib] Get rid of `emptyArray` in `thread-reducer`
ClosedPublic

Authored by atul on Jun 2 2022, 2:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 27, 2:30 PM
Unknown Object (File)
Sun, Nov 24, 12:27 AM
Unknown Object (File)
Sat, Nov 23, 11:36 PM
Unknown Object (File)
Sat, Nov 23, 6:28 PM
Unknown Object (File)
Nov 8 2024, 8:07 PM
Unknown Object (File)
Nov 7 2024, 8:34 PM
Unknown Object (File)
Nov 2 2024, 3:14 PM
Unknown Object (File)
Oct 30 2024, 6:27 AM

Details

Summary

This isn't used anywhere else and doesn't seem necessary? Seems like an unnecesary indirection instead of just placing an empty array (eg [])


Depends on D4195

Test Plan

Didn't test

Diff Detail

Repository
rCOMM Comm
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul requested review of this revision.Jun 2 2022, 2:15 PM
tomek requested changes to this revision.Jun 3 2022, 2:42 AM
tomek added inline comments.
lib/reducers/thread-reducer.js
156

It seems unlikely that it was added without a good reason. In this case, I guess there might be a place where we compare newInconsistencies with oldInconsistencies using referential equality and this change might break that: [] !== [], but emptyArray === emptyArray. Please investigate it.

This revision now requires changes to proceed.Jun 3 2022, 2:42 AM
atul requested review of this revision.Jun 17 2022, 12:54 PM

Re-requesting review after responding to comment.

lib/reducers/thread-reducer.js
156

That's a good point about keeping the reference the same for purposes of shallow equality.

However, we only use the findInconsistencies function for the processServerRequests action type. For all of the other action types we're returning a new empty array when there are no inconsistencies.

Further, at the reduceThreadInfos callsite in lib/reducers/master-reducer we almost immediately "spread" the value of newThreadInconsistencies "into" newInconsistencies.

Nowhere along the way do we do a shallow comparison of the inconsistencies array, so I think it's safe for it to be removed?

tomek added inline comments.
lib/reducers/thread-reducer.js
156

If we don't compare shallowly in any place, it should be ok

This revision is now accepted and ready to land.Jun 20 2022, 2:30 AM

rebase after cherrypicking and before landign

This revision was landed with ongoing or failed builds.Jun 21 2022, 9:34 PM
This revision was automatically updated to reflect the committed changes.