Skip to content

[Rigid/UniqueArray] Eliminate some duplicate bounds checks for UniqueArray - #699

Merged
Azoy merged 6 commits into
apple:mainfrom
Azoy:eliminate-duplicate-bounds-checks
Aug 12, 2026
Merged

[Rigid/UniqueArray] Eliminate some duplicate bounds checks for UniqueArray#699
Azoy merged 6 commits into
apple:mainfrom
Azoy:eliminate-duplicate-bounds-checks

Conversation

@Azoy

@Azoy Azoy commented Aug 12, 2026

Copy link
Copy Markdown
Member

UniqueArray had calls to _ensureFreeCapacity followed by calls to various RigidArray.append(*) which had its own bounds check. Split off the append logic from RigidArray into unchecked variants that it and UniqueArray can both call once they've done their bounds checking.

Checklist

  • I've read the Contribution Guidelines
  • My contributions are licensed under the Swift license.
  • I've followed the coding style of the rest of the project.
  • I've added tests covering all new code paths my change adds to the project (if appropriate).
  • I've added benchmarks covering new functionality (if appropriate).
  • I've verified that my change does not break any existing tests or introduce unexplained benchmark regressions.
  • I've updated the documentation if necessary.

@Azoy
Azoy requested a review from lorentey as a code owner August 12, 2026 19:28

@lorentey lorentey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 Does the optimizer not fold away the second check? (Are we tracking that issue?)

Comment thread Sources/BasicContainers/RigidArray/RigidArray+Append.swift Outdated
Comment thread Sources/BasicContainers/RigidArray/RigidArray+Append.swift Outdated
Comment thread Sources/BasicContainers/RigidArray/RigidArray+Append.swift Outdated
@lorentey lorentey added this to the 1.7.0 milestone Aug 12, 2026
@Azoy
Azoy merged commit f3e778f into apple:main Aug 12, 2026
75 checks passed
@Azoy
Azoy deleted the eliminate-duplicate-bounds-checks branch August 12, 2026 22:24
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