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

Implement IntoIterator for RpoDigest #216

Merged
merged 1 commit into from
Nov 7, 2023
Merged

Implement IntoIterator for RpoDigest #216

merged 1 commit into from
Nov 7, 2023

Conversation

plafer
Copy link
Contributor

@plafer plafer commented Nov 7, 2023

The primary purpose of this change is to be able to move an RpoDigest into a vector (without copy). This is especially useful when loading hashes into the vm's StackInputs.

let digest = Digest::default();
let vec = Vec::new();

vec.extend(digest);

Compare with our 2 suboptimal choices prior to this change:

let digest = Digest::default();
let vec = Vec::new();

// 1. one-liner, but requires a copy
{
    vec.append(digest.as_elements().to_vec());
}

// 2. Require an extra variable to perform a move
{
    let digest: [Felt; 4] = digest.into();
    vec.extend(digest);
}

@plafer plafer requested a review from bobbinth November 7, 2023 12:37
Copy link

sonarqubecloud bot commented Nov 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you!

@plafer plafer merged commit 9f0aaf6 into next Nov 7, 2023
11 checks passed
@plafer plafer deleted the plafer-digest-iter branch November 7, 2023 16:11
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