Skip to content

perf: avoid boxing in Kotlin struct equality and hashing - #2057

Merged
mrousavy merged 5 commits into
v1from
mrousavy/v1-kotlin-struct-equality
Nov 9, 2026
Merged

mrousavy merged 5 commits into
v1from
mrousavy/v1-kotlin-struct-equality

Conversation

@mrousavy

@mrousavy mrousavy commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Generated Kotlin structs box primitive fields in equals() and allocate a temporary object array in hashCode().

Generate comparisons and hashes directly through shared helpers for arrays, doubles and nullable values. Other types use ordinary Kotlin equality and hashing. Initialize hashes from the first field and return its hash directly for single-field structs. Struct hash values change.

Validated with Nitrogen build/typecheck/lint and full spec regeneration. Kotlin regression checks passed 942 equality comparisons, 206 equal-value hash checks and 2,826 hash collection lookups across 28 generated structs. Primitive-only equality and hashing bytecode contains no boxing or temporary arrays.

@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
nitro-docs Skipped Skipped Nov 9, 2026 8:58pm UTC

Request Review

@mrousavy
mrousavy merged commit db81de6 into v1 Nov 9, 2026
16 of 18 checks passed

This branch was previously deployed

1 inactive deployment
Preview — 7cad5799 Deployed Nov 9, 2026 by vercel[bot]
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.

1 participant