refactor(fold): introduce FoldContext to encapsulate state and simplify function signatures
Introduce a new FoldContext struct to group related fields (spaces, width, mode, writer, output, col_count, last_space) into a single context object. This refactoring reduces parameter passing in emit_output and process_utf8_line functions, improving code readability and maintainability without altering the core folding logic.
95d73d0
13 days ago
by mattsu2020
+13.73%
feat: optimize ASCII line processing in fold
Add process_ascii_line function to handle ASCII bytes efficiently, avoiding UTF-8 overhead for ASCII input. Update emit_output to properly manage output buffer remainder and track last space position for better folding logic. Modify process_utf8_line to delegate ASCII lines to the new function.
26906fe
12 days ago
by mattsu2020
-0.01%
refactor(fold): improve readability of last_space assignment in emit_output
Break the inline closure into a multi-line block for better code clarity and maintainability.
639a451
12 days ago
by mattsu2020
0%
fix(fold): correct space index condition in emit_output
The condition for updating the last space index was changed from `idx + 1 <= consume` to `idx < consume` to fix an off-by-one error, ensuring proper handling of spaces when consuming characters during line folding.
f468a41
12 days ago
by mattsu2020
×2.1
refactor(fold): optimize ASCII line processing for better character handling
Refactor the `process_ascii_line` function to use a while loop with pattern matching instead of a for loop, improving efficiency and clarity. Introduce `push_ascii_segment` to handle contiguous printable character sequences, ensuring accurate column counting and whitespace tracking in both columns and characters modes. This addresses potential issues with control character processing and width calculations.
9ed32fe
12 days ago
by mattsu2020
0%
refactor(fold): optimize ASCII line processing for better character handling
Refactor the `process_ascii_line` function to use a while loop with pattern matching instead of a for loop, improving efficiency and clarity. Introduce `push_ascii_segment` to handle contiguous printable character sequences, ensuring accurate column counting and whitespace tracking in both columns and characters modes. This addresses potential issues with control character processing and width calculations.