refactor pmmr functions, improve efficiency; panic on 0 pos1 #3663
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
name: fixmmr_part1
about: streamline MMR code
title: Fix MMR part 1
labels:
assignees: Yeastplume
This PR refactors pmmr.rs, improving efficiency and clarifying use of 0-based vs 1-based positions, introducing panics when passing 0 as a 1-based position, which makes no sense in normal use. The latter did require removal of corresponding test-cases.
A followup PR is planned to make all methods use 0-based positions, which are preferable for two reasons:
node_index = 2 * leaf_index - count_ones(leaf_index)
There appears to be no advantage to 1-based positions. The APIs use them though, so the API implementation is where all the conversion should take place.