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

Replace Vec References with slices in function inputs #3535

Merged
merged 8 commits into from
Feb 9, 2023

Conversation

asimm241
Copy link
Contributor

@asimm241 asimm241 commented Jan 27, 2023

Description

This PR replaces all vector references with slices. It uses Clippy's ptr_arg lint for reference.

Applicable issues

@codecov
Copy link

codecov bot commented Jan 27, 2023

Codecov Report

Merging #3535 (edd08e3) into develop (dab5d0b) will decrease coverage by 34.13%.
The diff coverage is 22.17%.

@@             Coverage Diff              @@
##           develop    #3535       +/-   ##
============================================
- Coverage    65.55%   31.43%   -34.13%     
============================================
  Files          240      298       +58     
  Lines       130905   275038   +144133     
============================================
+ Hits         85819    86450      +631     
- Misses       45086   188588   +143502     
Impacted Files Coverage Δ
clarity/src/vm/database/clarity_store.rs 61.81% <ø> (ø)
src/burnchains/bitcoin/bits.rs 8.90% <0.00%> (-16.51%) ⬇️
src/burnchains/tests/burnchain.rs 0.00% <0.00%> (ø)
src/burnchains/tests/db.rs 0.00% <0.00%> (ø)
src/burnchains/tests/mod.rs 0.00% <0.00%> (ø)
src/chainstate/coordinator/mod.rs 81.10% <ø> (-1.33%) ⬇️
src/chainstate/coordinator/tests.rs 0.00% <0.00%> (ø)
src/chainstate/stacks/auth.rs 10.45% <0.00%> (-33.58%) ⬇️
src/chainstate/stacks/db/transactions.rs 6.27% <0.00%> (-52.97%) ⬇️
src/chainstate/stacks/index/proofs.rs 33.52% <0.00%> (-0.17%) ⬇️
... and 224 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Comment on lines +672 to +674
pub fn new(path: &[u8]) -> TrieNode4 {
TrieNode4 {
path: path.clone(),
path: path.to_owned(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally speaking in scenarios like this one, I'd argue it's better to take the owned type as input instead of cloning a reference. So I'd change the input to path: Vec<u8>, leaving it up to the caller to decide when to clone.

I recognize that this is beyond the scope of the current refactor, so feel free to leave that for future improvements.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, don't do this.

Copy link
Contributor Author

@asimm241 asimm241 Jan 30, 2023

Choose a reason for hiding this comment

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

@netrome I have fixed where it could be simply fixed. Other places could produce ripples in the code and it should be done in a separate PR. I have created an issue to track that. #3540

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thank you!

Copy link
Contributor

@netrome netrome left a comment

Choose a reason for hiding this comment

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

Overall this looks good to me. You also need to update the announce_block implementation on line 454 in testnet/stacks-node/src/event_dispatcher.rs:454:19 to make testnet/stacks-node compile.

Copy link
Contributor

@pavitthrap pavitthrap left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for the PR!

Copy link
Member

@jcnelson jcnelson left a comment

Choose a reason for hiding this comment

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

Thanks @asimm241!

@jcnelson
Copy link
Member

jcnelson commented Feb 3, 2023

Need unit tests to pass before we can merge @asimm241

@jcnelson jcnelson merged commit 16f978c into stacks-network:develop Feb 9, 2023
@blockstack-devops
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@stacks-network stacks-network locked as resolved and limited conversation to collaborators Nov 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Status: Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants