Skip to content

Remove redundant FIXME comment#508

Merged
jdm merged 3 commits intoservo:masterfrom
organic1337:optimize_attr_dup_detection
Aug 27, 2023
Merged

Remove redundant FIXME comment#508
jdm merged 3 commits intoservo:masterfrom
organic1337:optimize_attr_dup_detection

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
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