Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant FIXME comment #508

Merged
merged 3 commits into from
Aug 27, 2023

Conversation

organic1337
Copy link
Contributor

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.

@jdm
Copy link
Member

jdm commented Aug 27, 2023

Thanks for the analysis!

@jdm jdm enabled auto-merge August 27, 2023 22:31
@jdm jdm added this pull request to the merge queue Aug 27, 2023
Merged via the queue into servo:master with commit ecbd26a Aug 27, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants