Skip to content

Optimize HTMLTree to_tuple conversion using Enum.reduce#657

Merged
philss merged 1 commit into
philss:mainfrom
preciz:optimize-enum-reduce
Mar 16, 2026
Merged

Optimize HTMLTree to_tuple conversion using Enum.reduce#657
philss merged 1 commit into
philss:mainfrom
preciz:optimize-enum-reduce

Conversation

@preciz

@preciz preciz commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Replaced Enum.reverse() |> Enum.map() with a single-pass Enum.reduce/3, eliminating double traversal for a performance and memory improvement.

Summary of Improvements

  • Big Input: ~42% faster (4.33 ms vs 6.16 ms), memory reduced by ~18% (1.39 MB vs 1.70 MB).
  • Medium Input: ~13% faster (578 μs vs 652 μs), memory reduced by ~14% (481 KB vs 562 KB).
  • Small Input: ~13% faster (65 μs vs 74 μs), memory reduced by ~16% (97 KB vs 116 KB).

Replaced Enum.reverse() |> Enum.map() with a single-pass Enum.reduce/3, eliminating double traversal for a performance and memory improvement.
@philss philss merged commit 5eda2f2 into philss:main Mar 16, 2026
6 checks passed
@philss

philss commented Mar 16, 2026

Copy link
Copy Markdown
Owner

@preciz awesome! thank you! 🚀

PS: I shall release a new patch version with your changes soon.

@preciz

preciz commented Mar 16, 2026

Copy link
Copy Markdown
Contributor Author

@preciz awesome! thank you! 🚀

PS: I shall release a new patch version with your changes soon.

Great, we heavily rely on Floki

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