Skip to content

Feat: Add clippy stackslib, pass indexing_slicing #6188

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

kantai
Copy link
Contributor

@kantai kantai commented Jun 9, 2025

This gets stackslib to pass the first lint listed in #6156

This does a couple of things in the refactor beyond just replacing foo[..] with foo.get(..)? in order to make the usage a little more idiomatic in rust:

  • More usage of TryInto<[u8; T]> -- we previously did a lot of buffering in our codebase to get from &[u8] into a [u8; T]. This not only involves indexing or invocations of copy_from_slice(), but it also is less performant.
  • More reliance on iterator operations like .take(), .chunks(), .zip(), and .skip(), etc.

Some of the previous avoidance of iterators (in MARF in particular) had comments indicating that iterators were slower than the alternatives (for loops, and even manual for loops). I'm not sure if that used to be the case in older versions of rustc, but as of this PR, there was no measurable difference when measured using the MARF benchmarks (with optimizations turned on: I think in unoptimized builds, there is a performance difference).

@kantai kantai requested review from a team as code owners June 9, 2025 17:50
@obycode obycode self-requested a review June 11, 2025 15:15
@aldur aldur moved this to Status: In Review in Stacks Core Eng Jun 11, 2025
@aldur aldur added this to the 3.1.0.0.13 milestone Jun 11, 2025
@aldur aldur requested review from Jiloc and hstove June 12, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants