Open
Conversation
- Rewrite ContentFrom() to scan chars directly instead of re-invoking the full tokenizer, eliminating double-tokenization - Cache single-char token strings via static lookup table, remove unused CssStringToken/CssUrlToken/CssCommentToken subclasses - Add ToLowerFast() to skip allocation when strings are already lowercase, use StringBuilder for custom property name concatenation - Replace @-rule if-else chain with dictionary dispatch, add dictionary index to CssStyleDeclaration for O(1) property lookups - Avoid double-array allocation in PeriodicValueConverter when all 4 values are present
Contributor
|
ToLowerFast maybe still could be optimized: |
Contributor
Author
|
@jogibear9988 I'll take a look and see what the benchmark says. |
Contributor
Author
Both runs confirm the same pattern:
CSS File Benchmark Comparison Existing PR vs adjusting to Span
Outcome observed, |
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.
Prerequisites
Please make sure you can check the following two boxes:
Contribution Type
What types of changes does your code introduce? Put an
xin all the boxes that apply:Description
ContentFrom()to scan chars directly instead of re-invoking the full tokenizer, eliminating double-tokenizationToLowerFast()to skip allocation when strings are already lowercase, use StringBuilder for custom property name concatenationPeriodicValueConverterwhen all 4 values are presentAngleSharp vs ExCss comparison (after optimizations)
Summary:
AngleSharp is now faster on 7 of 8 benchmark files and allocates 2–7× less memory than ExCss across all files.