Commit 77eb609
committed
Improved stateful surpasses() impl that hews closely to the NonISODateSurpasses spec
This is not ready to go, but I wanted to get some feedback.
Most of the following will not make sense until one has seen the code.
- The priority here is to stick to the spec, and avoid recalculation.
There are some clumsy aspects, like the need for the caller to
invoke the checker in a specific way:
1. Large fields to small fields.
2. Before moving from field A to field B, make a final
call with the computed value of field A, to set the internal
state correctly.
3. Caller maintains their own y/m/w/d.
I tried to work around unicode-org#2 and unicode-org#3, but couldn't come up with
anything clean. It seems like the current approach is a good
compromise.
- For the debug assertions, clippy complained that I was calling
a mut function. This is actually ok, because the object
is reset to a new state immediately afterwards. The workaround
to the clippy warning is expensive, but should be ok because it's
just for debug. I tried other approaches but didn't get anything
else to work. Adding an "allow" directive didn't work because
debug_assert! is a macro.
- There is now no in-library usage of surpasses(). All the testing
for that was via until() as far as I can tell. The work item is
to add test coverage for surpasses(), and once that looks good,
I will refactor surpasses() to use the stateful checker, to
optimize performance and eliminate duplicate code.
Also included: Minor edits to balance some backticks.1 parent 88a0c21 commit 77eb609
File tree
5 files changed
+242
-181
lines changed- components/calendar/src
- cal
5 files changed
+242
-181
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
| 389 | + | |
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
| 398 | + | |
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
| 404 | + | |
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
| |||
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
530 | | - | |
| 530 | + | |
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | | - | |
| 538 | + | |
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
544 | | - | |
| 544 | + | |
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1038 | 1038 | | |
1039 | 1039 | | |
1040 | 1040 | | |
1041 | | - | |
| 1041 | + | |
1042 | 1042 | | |
1043 | 1043 | | |
1044 | 1044 | | |
1045 | 1045 | | |
1046 | 1046 | | |
1047 | 1047 | | |
1048 | 1048 | | |
1049 | | - | |
| 1049 | + | |
1050 | 1050 | | |
1051 | 1051 | | |
1052 | 1052 | | |
| |||
0 commit comments