Skip to content
New issue

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

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

Already on GitHub? # to your account

List::from_parts could drop the depth parameter #46

Open
michaelsproul opened this issue Aug 20, 2024 · 1 comment
Open

List::from_parts could drop the depth parameter #46

michaelsproul opened this issue Aug 20, 2024 · 1 comment

Comments

@michaelsproul
Copy link
Member

michaelsproul commented Aug 20, 2024

Presently List::from_parts doesn't check that the depth passed in is correct. It is a pub(crate) function and is only intended for internal use where the depth has already been checked. Even so, we could make the API more correct by construction by omitting the depth parameter and deriving it from Self::depth, or by checking the depth and returning an error if it is incorrect. I think the first solution is preferable.

I think the parameter was only passed in as an optimisation to avoid computing it twice, but this is likely a very minor saving.

@michaelsproul
Copy link
Member Author

A similar consideration applies to the length passed in. It could be incorrect. However checking the length against the tree is expensive, so at most we could check that it is less than the capacity N.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant