date: drop pad flags before composite strftime specifiers - #14179
date: drop pad flags before composite strftime specifiers#14179MadeNavaneeth wants to merge 1 commit into
Conversation
| /// Neutralize the no-pad (`-`) and space-pad (`_`) GNU flags that sit | ||
| /// directly in front of a *composite* strftime specifier | ||
| /// (`%D %F %T %r %R %c %x %X`). | ||
| /// | ||
| /// In GNU `date` these specifiers expand to a fixed sequence of simpler | ||
| /// fields (`%D` → `%m/%d/%y`, etc.) and are treated as a single atomic unit: | ||
| /// any flag applied to the composite does **not** leak into the inner fields | ||
| /// (issue #11657). jiff, however, propagates a leading `-` or `_` into those | ||
| /// inner fields, so `%-D` yields `6/15/24` instead of GNU's `06/15/24`. | ||
| /// Dropping just these pad flags before jiff sees the string makes the | ||
| /// composite render as GNU does. | ||
| /// | ||
| /// Other modifiers (width digits, `0`/`^`/`#`/`+`) are deliberately left in | ||
| /// place: they do not leak into the inner fields, and they must survive so | ||
| /// the existing huge-width guard still fires for e.g. `%999999999999999999c`. | ||
| /// Only the pad flag characters `-` and `_` immediately preceding a composite | ||
| /// letter are removed; the composite itself is preserved verbatim. A dangling | ||
| /// `%` sequence is left alone. |
There was a problem hiding this comment.
do we need such a long comment ?
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] |
There was a problem hiding this comment.
please move that into test_date.rs instead
Merging this PR will improve performance by 23.79%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | complex_relative_date |
391.3 µs | 316.1 µs | +23.79% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing MadeNavaneeth:date-composite-modifier (5167654) with main (0d8310c)
Footnotes
-
402 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
GNU testsuite comparison: |
e5fe803 to
a283bca
Compare
|
Done:
The unit test in date.rs tests the private function directly and can't be moved to integration tests without making it public. The new integration test covers the same behavior through the CLI. |
GNU date treats composite specifiers (%D %F %T %r %R %c %x %X) as atomic, so a leading -/_ pad flag must not leak into the inner fields. jiff propagates the flag instead, e.g. %-D produced 6/15/24 rather than GNU's 06/15/24 (issue uutils#11657). Add strip_modifiers_on_composite, which removes only the pad flags immediately preceding a composite letter, and keep all other modifiers (width, 0 ^ # +) so the existing huge-width guard still fires. Fixes uutils#11657
a283bca to
5167654
Compare
GNU
datetreats composite specifiers (%D %F %T %r %R %c %x %X) as atomic, so a leading-/_pad flag must not leak into the inner fields. jiff propagates the flag instead, so%-Dproduced6/15/24rather than GNU's06/15/24(issue #11657).Add
strip_modifiers_on_composite, which removes only the pad flags immediately preceding a composite letter and keeps all other modifiers (width,0 ^ # +) so the existing huge-width guard still fires.Fixes #11657