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)
Fri, Nov 8, 8:07 PM
Unknown Object (File)
Thu, Nov 7, 8:34 PM
Unknown Object (File)
Sat, Nov 2, 3:14 PM
Unknown Object (File)
Wed, Oct 30, 6:27 AM
Unknown Object (File)
Oct 18 2024, 11:34 AM
Unknown Object (File)
Oct 17 2024, 2:25 AM
Unknown Object (File)
Oct 14 2024, 11:28 PM
Unknown Object (File)
Oct 8 2024, 8:55 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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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 ↗(On Diff #13311)

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 ↗(On Diff #13311)

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 ↗(On Diff #13311)

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.