You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: shorten some print functons && use string concat directly in some places (#179)
## Summary
This PR refactors multiple string-building operations throughout the CSS
formatter to use direct string concatenation instead of building arrays
and joining them. This simplifies the code and improves readability
while maintaining the same functionality.
## Key Changes
- **`print_operator()`**: Replaced array-based building with direct
concatenation using ternary operators to determine spacing rules
- **`print_declaration()`**: Changed `important` from array to string,
simplified the logic for extracting and formatting the `!important` flag
- **`print_nth()`**: Replaced parts array with direct string
concatenation and template literals
- **`print_nth_of()`**: Converted from array building to direct string
concatenation
- **`print_compound_selector()`**: Simplified to use `map().join()`
instead of manual forEach loop
- **`print_rule()`**: Moved `block_has_content` calculation to the top
to avoid duplication, simplified block rendering logic
- **`print_atrule()`**: Refactored name building from array to string
concatenation, consolidated `block_has_content` logic to avoid
recalculation, simplified return statements
## Notable Implementation Details
- All changes maintain the exact same output formatting and CSS
specification compliance
- The refactoring reduces intermediate array allocations and simplifies
control flow
- Comments explaining CSS specification requirements (e.g., spacing
around `+` and `-` operators) are preserved
https://claude.ai/code/session_01P6rhwrSj4m7rKSqqsPUqgz
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments