Commit 97987b4
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 080991a commit 97987b4
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 | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
| 404 | + | |
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | | - | |
| 413 | + | |
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
| 419 | + | |
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
| |||
548 | 548 | | |
549 | 549 | | |
550 | 550 | | |
551 | | - | |
| 551 | + | |
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
559 | | - | |
| 559 | + | |
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
565 | | - | |
| 565 | + | |
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1072 | 1072 | | |
1073 | 1073 | | |
1074 | 1074 | | |
1075 | | - | |
| 1075 | + | |
1076 | 1076 | | |
1077 | 1077 | | |
1078 | 1078 | | |
1079 | 1079 | | |
1080 | 1080 | | |
1081 | 1081 | | |
1082 | 1082 | | |
1083 | | - | |
| 1083 | + | |
1084 | 1084 | | |
1085 | 1085 | | |
1086 | 1086 | | |
| |||
0 commit comments