Commit 091361d
msglist [nfc]: Maintain middleItem as a field
This new logic maintains `middleItem` according to its documented
relationship with `middleMessage`. Because of the current
definition of `middleMessage`, that produces the same result as
the previous definition of `middleItem`.
The key reasoning for why this logic works is: this touches all the
code that modifies `items`, to ensure that code keeps `middleItem`
up to date. And all the code which modifies `messages` (which is
the only way to modify `middleMessage`) already calls
`_reprocessAll` to compute `items` from scratch, except one site
in `_addMessage`. Studying `_addMessage`, it also maintains
`middleItem` correctly, though for that conclusion one needs the
specifics of the definition of `middleMessage`.
This change involves no new test code: all this logic is in
scenarios well exercised by existing tests, and the invariant-checks
introduced in the previous commit then effectively test this logic.
To be sure of that, I also confirmed that commenting out any one of
these updates to `middleItem` causes some tests to fail.1 parent 36a5b84 commit 091361d
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| 298 | + | |
298 | 299 | | |
299 | 300 | | |
300 | 301 | | |
| |||
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
| 338 | + | |
337 | 339 | | |
338 | 340 | | |
339 | 341 | | |
| |||
344 | 346 | | |
345 | 347 | | |
346 | 348 | | |
| 349 | + | |
347 | 350 | | |
348 | 351 | | |
349 | 352 | | |
| |||
0 commit comments