Commit 489f48a
committed
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 0aec5c1 commit 489f48a
1 file changed
+4
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
| 166 | + | |
185 | 167 | | |
186 | 168 | | |
187 | 169 | | |
| |||
313 | 295 | | |
314 | 296 | | |
315 | 297 | | |
| 298 | + | |
316 | 299 | | |
317 | 300 | | |
318 | 301 | | |
| |||
352 | 335 | | |
353 | 336 | | |
354 | 337 | | |
| 338 | + | |
355 | 339 | | |
356 | 340 | | |
357 | 341 | | |
| |||
362 | 346 | | |
363 | 347 | | |
364 | 348 | | |
| 349 | + | |
365 | 350 | | |
366 | 351 | | |
367 | 352 | | |
| |||
0 commit comments