Skip to content

Optimize HTMLTree updates and deletions#685

Closed
preciz wants to merge 1 commit intophilss:mainfrom
preciz:optimize-html-tree-construction
Closed

Optimize HTMLTree updates and deletions#685
preciz wants to merge 1 commit intophilss:mainfrom
preciz:optimize-html-tree-construction

Conversation

@preciz
Copy link
Copy Markdown
Contributor

@preciz preciz commented Apr 17, 2026

  • Replace macro put_in/2 with explicit Map.put/3 update syntax in patch_nodes/2 for faster static map updates.
  • Replace Map.take/2 and Map.values/1 pipeline with a list comprehension in do_delete/3 for faster bulk node retrieval without intermediate allocations.

These optimizations provide an 5%-9% overall execution speed up to Floki's core mutation operations like Floki.find_and_update/3, Floki.filter_out/2, and Floki.attr/4 when manipulating large documents.

- Replace macro put_in/2 with explicit Map.put/3 update syntax in patch_nodes/2 for faster static map updates.
- Replace Map.take/2 and Map.values/1 pipeline with a list comprehension in do_delete/3 for faster bulk node retrieval without intermediate allocations.

These targeted optimizations provide an 5%-9% overall execution speed up to Floki's core mutation operations like Floki.find_and_update/3, Floki.filter_out/2, and Floki.attr/4 when manipulating large documents.
@preciz
Copy link
Copy Markdown
Contributor Author

preciz commented Apr 17, 2026

Will open another PR instead.

@preciz preciz closed this Apr 17, 2026
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.

1 participant