Skip to content

Optimize multiple selectors deduping#667

Merged
philss merged 1 commit into
philss:mainfrom
preciz:optimize-find-uniq-by
Apr 10, 2026
Merged

Optimize multiple selectors deduping#667
philss merged 1 commit into
philss:mainfrom
preciz:optimize-find-uniq-by

Conversation

@preciz
Copy link
Copy Markdown
Contributor

@preciz preciz commented Apr 9, 2026

Use Enum.uniq_by/2 with the node_id integer instead of relying on
Enum.uniq/1's deep structural equality over large HTMLNode
structs.

Moving the de-duplication before the sort results in less elements
to be sorted, reducing the list that goes into the sort.

It's only 1-3% faster but it's also a simplification.

Use `Enum.uniq_by/2` with the `node_id` integer instead of relying on
`Enum.uniq/1`'s deep structural equality over massive `HTMLNode`
structs.

Moving the de-duplication before the sort also results in less elements
to be sorted, reducing the list that goes into the O(N log N) sort.
@philss philss merged commit 7069ca6 into philss:main Apr 10, 2026
6 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