Skip to content

Optimize HTMLTree updates and deletions#687

Merged
philss merged 1 commit intophilss:mainfrom
preciz:optimize-html-tree-construction2
Apr 17, 2026
Merged

Optimize HTMLTree updates and deletions#687
philss merged 1 commit intophilss:mainfrom
preciz:optimize-html-tree-construction2

Conversation

@preciz
Copy link
Copy Markdown
Contributor

@preciz preciz commented Apr 17, 2026

  • Accumulate deleted IDs to avoid O(N^2) List.delete overhead.
  • Use Map.put instead of put_in for map updates.
  • Use list comprehension instead of Map.take |> Map.values.

Performance improvements:

  • ~100x speedup and ~200x less memory usage for filter_out in some benchmarks I ran with the big.html file
  • ~1.3x speedup for find_and_update on large HTMLs

- Accumulate deleted IDs to avoid O(N^2) List.delete overhead.
- Use Map.put instead of put_in for map updates.
- Use list comprehension instead of Map.take |> Map.values.
@philss philss merged commit a5cd540 into philss:main Apr 17, 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