Skip to content

Inline zerocopy layout helpers#3481

Merged
joshlf merged 2 commits into
mainfrom
codex/apply-changes-from-provided-diff
Jul 8, 2026
Merged

Inline zerocopy layout helpers#3481
joshlf merged 2 commits into
mainfrom
codex/apply-changes-from-provided-diff

Conversation

@joshlf

@joshlf joshlf commented Jul 8, 2026

Copy link
Copy Markdown
Member

Motivation

  • Encourage the compiler to inline small, hot helpers used during layout computation to improve performance and reduce call overhead in const/inline-heavy code paths.

Description

  • Add #[inline(always)] to SizeInfo::try_to_nonzero_elem_size in zerocopy/src/layout.rs.
  • Add #[inline(always)] to padding_needed_for in zerocopy/src/util/mod.rs.
  • Add #[inline(always)] to max and min helpers for NonZeroUsize in zerocopy/src/util/mod.rs.
  • Applied changes to the zerocopy/src/ files (the requested rust/Makefile hunk was not present in this repository so it was not applied).

Testing

  • Ran CARGO_ZEROCOPY_AUTO_INSTALL_TOOLCHAIN=1 ./cargo.sh +stable check --tests --features __internal_use_only_features_that_work_on_stable, which completed successfully.
  • Ran git diff --check, which reported no issues.
  • Invoked the repository githooks/pre-push which produced warnings about missing tools and interactive toolchain installation prompts, so it did not fully complete in this environment.

Codex Task

@joshlf joshlf requested a review from jswrenn July 8, 2026 16:52
@joshlf joshlf enabled auto-merge July 8, 2026 16:52

@jswrenn jswrenn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should use the CFG introduced in #3139.

@joshlf

joshlf commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

This should use the CFG introduced in #3139.

Done.

@joshlf joshlf added this pull request to the merge queue Jul 8, 2026
Merged via the queue into main with commit fbe9f18 Jul 8, 2026
128 checks passed
@joshlf joshlf deleted the codex/apply-changes-from-provided-diff branch July 8, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants