Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve @immut/array::from_iter #1752

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

illusory0x0
Copy link
Contributor

That is exactly what Clojure’s persistent vector does, and it is done through balanced, ordered trees.

persistent vector is implemented using balanced tree and share Path during update/insert/remove, using Array as buffer avoids creating a lot of @immut/array[T].

@coveralls
Copy link
Collaborator

coveralls commented Mar 9, 2025

Pull Request Test Coverage Report for Build 5628

Details

  • 15 of 16 (93.75%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 92.55%

Changes Missing Coverage Covered Lines Changed/Added Lines %
immut/array/array.mbt 15 16 93.75%
Totals Coverage Status
Change from base Build 5623: 0.002%
Covered Lines: 6025
Relevant Lines: 6510

💛 - Coveralls

Copy link
Collaborator

@peter-jerry-ye peter-jerry-ye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not ideal when handling large Array as this would also introduce resizing.

It would be better to allocate an FixedArray of size branching_factor, and then insert it to the tree.

@illusory0x0
Copy link
Contributor Author

illusory0x0 commented Mar 10, 2025

This is not ideal when handling large Array as this would also introduce resizing.

It would be better to allocate an FixedArray of size branching_factor, and then insert it to the tree.

The new_by_leaves implementation will do this

@illusory0x0 illusory0x0 force-pushed the improve-immut_array_from_iter branch 2 times, most recently from 29ccadc to 68f2950 Compare March 10, 2025 16:51
@illusory0x0 illusory0x0 force-pushed the improve-immut_array_from_iter branch from fc56e2f to b61558d Compare March 10, 2025 20:55
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.

3 participants