Refactor indent Filter Implementation#466
Merged
Kijewski merged 6 commits intoaskama-rs:masterfrom May 29, 2025
Merged
Conversation
Refactored the `indent` filter implementation to introduce the `IndentWriter` struct, eliminating the need for memory allocation. Removed the `MAX_LEN` restriction and the `fuzzed_indent_filter` test, as they are no longer necessary with the new approach. Fixes askama-rs#465.
Relocated the `indent` filter implementation from alloc.rs to a new indent.rs file,
as it no longer requires memory allocation.
Updated module imports and exports in filters/mod.rs to reflect this change.
Removed unused dependencies
(Cow, Deref, Pin) from alloc.rs.
Collaborator
|
Solid start. Almost nothing to be changed, well done! In addition to my comments, please also update the book "filters" chapter to remove the mention of the |
Updated the "filters" chapter in the book to remove the mention of the alloc feature requirement for the indent filter, as it no longer relies on memory allocation.
GuillaumeGomez
previously approved these changes
May 29, 2025
Collaborator
|
Looks good to me, thanks! Waiting for @Kijewski's review now. 😄 |
Kijewski
requested changes
May 29, 2025
Fix logic issue where `self.first` was not tracked across calls, causing incorrect indentation. Replaced `idx` with `is_first_line` flag. Added `test_indent_chunked` to verify correct behavior.
Kijewski
approved these changes
May 29, 2025
Member
Kijewski
left a comment
There was a problem hiding this comment.
Thank you very much for fixing the problem! Good idea to add a test that splits up the input!
This was referenced Jun 1, 2025
Closed
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.
Description
This PR refactors the
indentfilter:indentfilter to useIndentWriter, eliminating memory allocation, removingMAX_LENrestriction, and dropping thefuzzed_indent_filtertest.indentfilter fromalloc.rsto a newindent.rsfile, as it no longer requires memory allocation, and updated module imports/exports.Special thanks to @Kijewski for their suggestion in issue #465 to rewrite the filter without intermediate allocations, which inspired this optimization.
Changes
indentfilter to useIndentWriter, removing memory allocation andMAX_LEN.indentfilter toindent.rs, removed unused dependencies (Cow,Deref,Pin) fromalloc.rs, and updatedfilters/mod.rs.Testing
indentfilter pass.fuzzed_indent_filtertest as it's no longer relevant.Related Issues
indentfilter fails to apply indentation for large input strings #465