Skip to content

Reduce spare capacity in metadata lookup vectors - #5465

Merged
Kenny Kerr (kennykerr) merged 1 commit into
masterfrom
bindgen-startup
Nov 22, 2026
Merged

Kenny Kerr (kennykerr) merged 1 commit into
masterfrom
bindgen-startup

Conversation

@kennykerr

Copy link
Copy Markdown
Collaborator

Most names have only one definition, so start their vectors at capacity one instead of growing from empty. Duplicate names still grow normally.

With the bundled Win32 and WinRT metadata on x64, this saves about 72 MiB of vector backing storage across metadata and bindgen and improves generation time. Generated output is unchanged.

Copilot AI left a comment

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.

🟢 Approval recommended

There are no active review issues for the capacity-one allocation changes in metadata and bindgen name lookups.

No open issues 🎉

What changed in this PR

This PR reduces spare vector capacity in metadata and bindgen name lookups by starting each new per-name vector at capacity one. Duplicate names can still grow normally.

Changes:

  • Use capacity-one vectors for metadata type, function, and constant lookups.
  • Apply the same allocation strategy to bindgen's type lookup helper.
File Description
crates/​libs/​metadata/​src/​reader/​index.rs Initialize per-name lookup vectors with capacity one.
crates/​libs/​bindgen/​src/​winmd/​reader.rs Initialize type lookup vectors with capacity one.

Review effort: Balanced

@kennykerr
Kenny Kerr (kennykerr) merged commit c9e1b3b into master Nov 22, 2026
50 checks passed
@kennykerr
Kenny Kerr (kennykerr) deleted the bindgen-startup branch November 22, 2026 00:05
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