Skip to content

Mark _Word.allBits as @inlinable - #704

Merged
lorentey merged 1 commit into
mainfrom
dn/all-bits-inlineable
Aug 18, 2026
Merged

Mark _Word.allBits as @inlinable#704
lorentey merged 1 commit into
mainfrom
dn/all-bits-inlineable

Conversation

@dnadoba

@dnadoba dnadoba commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Probably by accident @inlinable was left out here. Ideally we would eventually move to the official non underscore @inline(always) variant that implies @inlinable and would make this not look like it get's inlined but only within the module like it was before this patch. But that requires Swift 6.3+.

This has a surprisingly big effect on some algorithms. Over 10x for BitArray.fill(with: true) and BitSet.fromUnion given a Range:
PNG image

PNG image

Some other see "minor" improvements as well:

PNG image PNG image PNG image

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.

@dnadoba
dnadoba requested a review from lorentey as a code owner August 14, 2026 23:39
Comment on lines +253 to 256
@inlinable
@inline(__always)
package static var allBits: Self {
Self(UInt.max)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the only real change, the rest is just benchmarks.

@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.

D'oh, good catch! 💯

@lorentey lorentey added this to the 1.7.0 milestone Aug 18, 2026
@lorentey
lorentey merged commit 78798e7 into main Aug 18, 2026
75 checks passed
@lorentey
lorentey deleted the dn/all-bits-inlineable branch August 18, 2026 20:49
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