Skip to content

binary-merkle-tree: preallocate proof vector to avoid reallocations#12288

Open
PSYKYODAI wants to merge 4 commits into
paritytech:masterfrom
PSYKYODAI:BMT-ops
Open

binary-merkle-tree: preallocate proof vector to avoid reallocations#12288
PSYKYODAI wants to merge 4 commits into
paritytech:masterfrom
PSYKYODAI:BMT-ops

Conversation

@PSYKYODAI

Copy link
Copy Markdown
Contributor

resolves #9106

if number_of_leaves <= 1 {
0
} else {
(number_of_leaves - 1).ilog2() as usize + 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@StackOverflowExcept1on StackOverflowExcept1on Jun 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's better to handle all errors/possible runtime panics to reduce code size, etc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! Suggestions have been applied.

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.

binary-merkle-tree: optimize ProofCollection by preallocating proof with size ceil(log2(n))

2 participants