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.
Background
While searching for potential points in the code to which I could contribute I came across this FIXME comment
which seemed like an easy-win:
// FIXME: linear time search, do we care?
(line 511 in
html5ever/src/tokenizer/mod.rs
)Fix attempt
I Tries using a HashSet for the attributes names so the search's complexity would be O(1) instead of O(n), as
can be seen in this commit
and once I ran some benchmarks on multiple websites (by modifying the noop-tokenizer example) I realized I only made things worst, the Parsing process took a tiny bit longer than before. This is probably because of the overhead within maintaining a HashSet of the attributes names, and because most elements do not have enough attributes for the HashSet to improve performance.
Conclusion
I think it's a good Idea to remove this comment so no one else will try to optimize this section for no reason.