Conversation
…eplacement is shorter. Currently if ReduceTimeUnits encounters a length like `0050ms`, it will translate it to `.05s` despite `50ms` and `.05s` being equivalent lengths. This is due to it counting the length of the uncompacted cursor. This change introduces a new `may_compact()` method in SourceCursor which uses quick heuristics to determine if a cursor could be compacted. This let's us check if we should then calculate the compacted length of the cursor to see if compaction is sufficient to minify the unit. The result is that "bloated" dimensions like `0050ms` won't switch units unnecessarily, and will instead allow the CompactCursorWriteSink to do its thing and translate it to `50ms`.
github-actions bot
pushed a commit
that referenced
this pull request
Jan 25, 2026
## [0.0.15] - 2026-01-25 ### Css_ast - css_ast/csskit_derives: Add derive(NodeWithMetadata) (#824) ([#824](#824)) - css_ast/csskit_derive/csskit_proc_macro: Add "constrainable" generics. (#825) ([#825](#825)) - css_ast/css_lexer: Preserve sign in an+b, otherwise compact (#828) ([#828](#828)) - css_ast: Don't preserve sign for integer An+B selectors. (#829) ([#829](#829)) ### Css_lexer - csskit_transform/css_lexer: Check compacted lengths to determine if replacement is shorter. (#827) ([#827](#827)) [forcebuild]
Merged
github-actions bot
pushed a commit
that referenced
this pull request
Jan 25, 2026
## [0.0.15] - 2026-01-25 ### Css_ast - css_ast/csskit_derives: Add derive(NodeWithMetadata) (#824) ([#824](#824)) - css_ast/csskit_derive/csskit_proc_macro: Add "constrainable" generics. (#825) ([#825](#825)) - css_ast/css_lexer: Preserve sign in an+b, otherwise compact (#828) ([#828](#828)) - css_ast: Don't preserve sign for integer An+B selectors. (#829) ([#829](#829)) ### Css_lexer - csskit_transform/css_lexer: Check compacted lengths to determine if replacement is shorter. (#827) ([#827](#827))
github-actions bot
pushed a commit
that referenced
this pull request
Jan 26, 2026
## [0.0.15] - 2026-01-26 ### Css_ast - css_ast/csskit_derives: Add derive(NodeWithMetadata) (#824) ([#824](#824)) - css_ast/csskit_derive/csskit_proc_macro: Add "constrainable" generics. (#825) ([#825](#825)) - css_ast/css_lexer: Preserve sign in an+b, otherwise compact (#828) ([#828](#828)) - css_ast: Don't preserve sign for integer An+B selectors. (#829) ([#829](#829)) - Regenerate css_ast/src/values from csswg drafts (#830) ([#830](#830)) ### Css_lexer - csskit_transform/css_lexer: Check compacted lengths to determine if replacement is shorter. (#827) ([#827](#827)) ### Csskit - chore(deps): update dependencies (patch) (#831) ([#831](#831)) [forcebuild]
github-actions bot
pushed a commit
that referenced
this pull request
Jan 26, 2026
## [0.0.15] - 2026-01-26 ### Css_ast - css_ast/csskit_derives: Add derive(NodeWithMetadata) (#824) ([#824](#824)) - css_ast/csskit_derive/csskit_proc_macro: Add "constrainable" generics. (#825) ([#825](#825)) - css_ast/css_lexer: Preserve sign in an+b, otherwise compact (#828) ([#828](#828)) - css_ast: Don't preserve sign for integer An+B selectors. (#829) ([#829](#829)) - Regenerate css_ast/src/values from csswg drafts (#830) ([#830](#830)) ### Css_lexer - csskit_transform/css_lexer: Check compacted lengths to determine if replacement is shorter. (#827) ([#827](#827)) ### Csskit - chore(deps): update dependencies (patch) (#831) ([#831](#831))
github-actions bot
pushed a commit
that referenced
this pull request
Jan 26, 2026
## [0.0.15] - 2026-01-26 ### Css_ast - css_ast/csskit_derives: Add derive(NodeWithMetadata) (#824) ([#824](#824)) - css_ast/csskit_derive/csskit_proc_macro: Add "constrainable" generics. (#825) ([#825](#825)) - css_ast/css_lexer: Preserve sign in an+b, otherwise compact (#828) ([#828](#828)) - css_ast: Don't preserve sign for integer An+B selectors. (#829) ([#829](#829)) - Regenerate css_ast/src/values from csswg drafts (#830) ([#830](#830)) ### Css_lexer - csskit_transform/css_lexer: Check compacted lengths to determine if replacement is shorter. (#827) ([#827](#827)) ### Csskit - chore(deps): update dependencies (patch) (#831) ([#831](#831)) ### Csskit_vscode - chore(deps): update dependency oxlint to v1.40.0 (#834) ([#834](#834)) [forcebuild]
github-actions bot
pushed a commit
that referenced
this pull request
Jan 26, 2026
## [0.0.15] - 2026-01-26 ### Css_ast - css_ast/csskit_derives: Add derive(NodeWithMetadata) (#824) ([#824](#824)) - css_ast/csskit_derive/csskit_proc_macro: Add "constrainable" generics. (#825) ([#825](#825)) - css_ast/css_lexer: Preserve sign in an+b, otherwise compact (#828) ([#828](#828)) - css_ast: Don't preserve sign for integer An+B selectors. (#829) ([#829](#829)) - Regenerate css_ast/src/values from csswg drafts (#830) ([#830](#830)) ### Css_lexer - csskit_transform/css_lexer: Check compacted lengths to determine if replacement is shorter. (#827) ([#827](#827)) ### Csskit - chore(deps): update dependencies (patch) (#831) ([#831](#831)) ### Csskit_vscode - chore(deps): update dependency oxlint to v1.40.0 (#834) ([#834](#834))
github-actions bot
pushed a commit
that referenced
this pull request
Jan 26, 2026
## [0.0.15] - 2026-01-26 ### Css_ast - css_ast/csskit_derives: Add derive(NodeWithMetadata) (#824) ([#824](#824)) - css_ast/csskit_derive/csskit_proc_macro: Add "constrainable" generics. (#825) ([#825](#825)) - css_ast/css_lexer: Preserve sign in an+b, otherwise compact (#828) ([#828](#828)) - css_ast: Don't preserve sign for integer An+B selectors. (#829) ([#829](#829)) - Regenerate css_ast/src/values from csswg drafts (#830) ([#830](#830)) ### Css_lexer - csskit_transform/css_lexer: Check compacted lengths to determine if replacement is shorter. (#827) ([#827](#827)) - css_lexer: De-duplicate escape sequence consumption (#835) ([#835](#835)) ### Csskit - chore(deps): update dependencies (patch) (#831) ([#831](#831)) ### Csskit_vscode - chore(deps): update dependency oxlint to v1.40.0 (#834) ([#834](#834)) [forcebuild]
github-actions bot
pushed a commit
that referenced
this pull request
Jan 26, 2026
## [0.0.15] - 2026-01-26 ### Css_ast - css_ast/csskit_derives: Add derive(NodeWithMetadata) (#824) ([#824](#824)) - css_ast/csskit_derive/csskit_proc_macro: Add "constrainable" generics. (#825) ([#825](#825)) - css_ast/css_lexer: Preserve sign in an+b, otherwise compact (#828) ([#828](#828)) - css_ast: Don't preserve sign for integer An+B selectors. (#829) ([#829](#829)) - Regenerate css_ast/src/values from csswg drafts (#830) ([#830](#830)) ### Css_lexer - csskit_transform/css_lexer: Check compacted lengths to determine if replacement is shorter. (#827) ([#827](#827)) - css_lexer: De-duplicate escape sequence consumption (#835) ([#835](#835)) ### Csskit - chore(deps): update dependencies (patch) (#831) ([#831](#831)) ### Csskit_vscode - chore(deps): update dependency oxlint to v1.40.0 (#834) ([#834](#834))
keithamus
added a commit
that referenced
this pull request
Jan 28, 2026
## [0.0.15] - 2026-01-26 ### Css_ast - css_ast/csskit_derives: Add derive(NodeWithMetadata) (#824) ([#824](#824)) - css_ast/csskit_derive/csskit_proc_macro: Add "constrainable" generics. (#825) ([#825](#825)) - css_ast/css_lexer: Preserve sign in an+b, otherwise compact (#828) ([#828](#828)) - css_ast: Don't preserve sign for integer An+B selectors. (#829) ([#829](#829)) - Regenerate css_ast/src/values from csswg drafts (#830) ([#830](#830)) ### Css_lexer - csskit_transform/css_lexer: Check compacted lengths to determine if replacement is shorter. (#827) ([#827](#827)) - css_lexer: De-duplicate escape sequence consumption (#835) ([#835](#835)) ### Csskit - chore(deps): update dependencies (patch) (#831) ([#831](#831)) ### Csskit_vscode - chore(deps): update dependency oxlint to v1.40.0 (#834) ([#834](#834)) [forcebuild]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently if ReduceTimeUnits encounters a length like
0050ms, it willtranslate it to
.05sdespite50msand.05sbeing equivalent lengths. Thisis due to it counting the length of the uncompacted cursor.
This change introduces a new
may_compact()method in SourceCursor which usesquick heuristics to determine if a cursor could be compacted. This let's us
check if we should then calculate the compacted length of the cursor to see if
compaction is sufficient to minify the unit.
The result is that "bloated" dimensions like
0050mswon't switch unitsunnecessarily, and will instead allow the CompactCursorWriteSink to do its thing
and translate it to
50ms.