66 Commits
Author SHA1 Message Date
Karoy Lorentey 8d0a2dfceb Deque: Make the empty singleton immortal 2026-11-06 16:06:08 -08:00
Karoy Lorentey d804d39ca6 Work around optimizer bug in Swift 6.2 even harder 2026-11-05 17:57:03 -08:00
Karoy Lorentey a99833003c Work around optimizer bug in Swift 6.2 (memory leaks due to miscompiled bulk deinitialization) 2026-11-05 17:40:46 -08:00
Karoy Lorentey bbdd37ada7 Fix a variety of issues in the nextSpan/previousSpan method family 2026-10-21 19:56:55 -07:00
Karoy Lorentey 24339ad6a3 CMake: Remove obsolete references to source variables 2026-10-12 12:24:03 -07:00
Karoy Lorentey 961043b4b2 Fix _RopeModule’s CMake config in single-module mode 2026-10-08 18:51:51 -07:00
Karoy Lorentey 1b936eda0b Disable strict memory safety on older toolchains
It would take too much effort to try to mitigate stdlib differences.

Fix low-hanging warnings, but turn off `.strictMemorySafety` on older toolchains by splitting the package manifest.
2026-10-01 13:40:27 -07:00
Karoy Lorentey d07dc32dfa Sources: Add unsafe keywords where needed 2026-10-01 11:14:29 -07:00
Karoy Lorentey c991c8543a Update SortedCollections for un-@testable testing 2026-09-29 18:32:58 -07:00
Karoy Lorentey f1e675acd2 Turn off BorrowingIteratorProtocol.next()
The reference to `Ref` appears to trigger a broken strong linkage to `_swift_initBorrow`, despite the code being only available on macOS/iOS/etc 27.
2026-09-25 15:01:04 -07:00
Karoy Lorentey 1a1818df8f Drop unused Optional._borrow, ._mutate and _insert definitions 2026-09-23 15:45:26 -07:00
Karoy Lorentey 537bf9cbfb Drop support for Swift 6.0 and 6.1
This allows the use of Span types without `#if compiler` guards.
2026-09-21 13:34:39 -07:00
Karoy Lorentey d392f0cbff MutableContainer: Add tests; resolve issues uncovered 2026-09-21 09:54:29 -07:00
Karoy Lorentey c031de73d0 MutableContainer: Add some bulk update operations 2026-09-16 19:58:28 -07:00
Karoy Lorentey 842f125c47 Invert dependencies to ContainersPreview, moving all container APIs there
- Move `InputSpan` into its own module, `SpanPreview`. Add dependencies to it.
- Invert dependencies to `ContainersPreview`, so that no production target imports it, but it now depends on its previous dependents.
- Move all generic APIs and conformances using `Producer`/`Drain`/`Container` to the `ContainersPreview` module.
- Remove `UnstableContainersPreview` conditions around `Iterable` APIs

In summary, importing `BasicContainers` and `DequeModule` continue to get us the basic definitions for `RigidArray`, `UniqueSet`, `RigidDeque` etc., without most of their unstable APIs. (With the exception of core APIs that require `InputSpan`.)

To get any API that uses an unstable protocol like `Container` or `Drain`, we’ll now need to import `ContainersPreview` in addition to the type-defining module.

This will provide a slightly less horrible migration path when (if) the container/producer protocol family gets adopted/adapted into the stdlib.
2026-08-25 18:29:58 -07:00
Karoy Lorentey f425dffd5b Merge pull request #702 from apple/dn/bit-set-count
Improve `BitSet.count` performance by ~3x
2026-08-18 13:54:33 -07:00
David Nadoba 962d21d92d Mark _Word.allBits as @inlinable 2026-08-14 16:32:50 -07:00
David Nadoba 8a050cd30d Improve BitSet.count performance 2026-08-13 13:52:01 -07:00
Alejandro Alonso 4e6dc1b9dc Update CMakeLists.txt 2026-07-22 15:07:46 -07:00
Alejandro Alonso 389f79fd11 Fix unsafe pointer sources for older compiles 2026-07-22 15:07:45 -07:00
Alejandro Alonso 7f05a23266 Update CMakeLists.txt
Update CMakeLists.txt
2026-07-22 15:07:44 -07:00
Alejandro Alonso cbdda61d5d Split up the buffer pointer in RIgidArray 2026-07-22 15:07:41 -07:00
Karoy Lorentey e70b4df228 Introduce Container.nextSpan(after:maxCount:limitedBy:) and make it the core Container primitive 2026-07-18 14:14:13 -07:00
Karoy Lorentey 3ba8d70ec3 Review and update container protocols and conformances
- @inlinable → @_alwaysEmitIntoClient for now, to avoid temporary ABI issues
- Review RangeReplaceableContainer algorithms; add missing ones:
    - New requirements: `removeFirst()`, `removeFirst(_:)`, `_customRemoveLast()`, `_customRemoveLast(_:) (with default implementations)
    - `func removeAll()`
    - `func removeLast()`, `func removeLast(_:)`, `func popLast()` when self is also bidirectional
- Review RigidArray, UniqueArray algorithms; remove ones needlessly duplicating functionality already provided by RRC. Try not to break source compatibility.
2026-07-07 14:18:09 -07:00
Karoy Lorentey 281d0a859d [InternalCollectionsUtilities] Update set of lifetime overrides 2026-07-07 14:18:09 -07:00
Karoy Lorentey d0a3207e39 [InternalCollectionsUtilities] Define _pointee property on pointer types with borrow/mutate accessors 2026-07-07 14:18:09 -07:00
Karoy Lorentey 130d235b28 Resolve issues after rebase 2026-06-18 13:29:52 -07:00
Karoy Lorentey de3b9b67be [ContainersPreview] Move helpers to InternalCollectionsUtilities 2026-06-18 13:20:38 -07:00
Aditya Singh 0a3dcfd3a8 [InternalCollectionsUtilities] Fix _trim returning the wrong buffer region
The `_trim(first:)` and `_trim(last:)` helpers reassign `self` to the
remaining slice and then build the trimmed result from `self`'s now-updated
`baseAddress`/`count`, so they hand back a region that points into the wrong
place in the buffer.

`UnsafeMutableBufferPointer._trim(first:)` had this exact bug fixed earlier (it
captures `oldStart` before the reassignment), but three sibling helpers were
left untouched:

  * `UnsafeBufferPointer._trim(first:)` reads `baseAddress` after advancing
    `self`, so the returned prefix starts at the remainder instead of at the
    original head.
  * `UnsafeBufferPointer._trim(last:)` and
    `UnsafeMutableBufferPointer._trim(last:)` recompute `count &- cut` after
    shrinking `self`, so the returned suffix starts `cut` elements too early.

For a five-element buffer, `_trim(first: 2)` returned the bytes of `[30, 40]`
rather than `[10, 20]`, and `_trim(last: 2)` returned `[20, 30]` rather than
`[40, 50]`; trimming more than the count walked off the end of the buffer.

Capture the original start (and, for the suffix case, the post-trim count)
before mutating `self`, matching the already-correct `_trim(first:)` on the
mutable buffer. Adds direct tests covering both overloads on both buffer types.
2026-05-24 18:22:45 -07:00
Franz Busch 3c373b900c Use the defines from traits directly
Package traits already pass defines with their trait name when building. Instead of adding our own conditional defines based on the traits we can use the trait provided defines directly. I observed that various tooling behaves better with the trait provided defines.
2026-05-06 07:41:02 -07:00
Franz Busch c12dabe1b8 Fix _trim(first:) returning wrong buffer region
After reassigning self on line 160, baseAddress on line 161 resolves to the new self's baseAddress (oldStart + cut) instead of the original start. This causes the returned buffer to point past the actual elements into uninitialized memory. Use the captured oldStart instead.
2026-04-25 00:09:23 +02:00
Karoy Lorentey a9b64d4f09 [BasicContainers] RigidArray,UniqueArray: Add Equatable conformance on Swift 6.4
This is currently conditional on the UnstableContainersPreview trait. (Swift 6.4 has not shipped yet, so we cannot unconditionally enable this without risking breakage.)
2026-04-08 18:31:11 -07:00
Karoy Lorentey 11443c0531 Enforce uniform license headers 2026-03-07 10:26:28 -08:00
Karoy Lorentey 1c69635852 Add SPDX-License-Identifier tags 2026-03-05 19:39:24 -08:00
Karoy Lorentey 11a49663d0 [Benchmarks] Update benchmarking sub-package
- Fix issues with the main package no longer exposing internal helper functions
- Move Rust benchmarks behind an EnableRustBenchmarks trait
- Allow traits to be enabled in `Utils/run-benchmarks.sh` through the BENCHMARK_TRAITS environment variable.
2026-03-05 19:39:22 -08:00
Karoy Lorentey d9b09ecde8 Update copyright dates 2026-03-05 19:39:20 -08:00
Karoy Lorentey 3941dab5b0 [BasicContainers] Implement removals on RigidSet and UniqueSet
Dictionaries are still to be done.
2026-02-20 18:19:51 -08:00
Karoy Lorentey bf9a7033a0 [BasicContainers] Add early drafts for RigidSet/RigidDictionary 2026-02-16 17:15:59 -08:00
Karoy Lorentey e4a874b67a Rigid & Unique types: Add Equatable, Hashable, Custom[Debug]StringConvertible operations
Currently these are all conditional on copyable elements, and the types cannot conform to the actual protocols yet.
2026-02-04 23:24:08 -08:00
Karoy Lorentey 9503f8fe57 Improve consistency of precondition failure messages
More uniform message strings should feel better, and they should ever so slightly reduce code size.
2026-02-04 10:27:17 -08:00
Karoy Lorentey 4c9a0da7f1 Update CMake configuration 2026-01-26 12:31:36 -08:00
Karoy Lorentey 76fa120c27 More RigidDeque testing 2026-01-26 11:18:57 -08:00
Karoy Lorentey 70a36c2c47 RigidDeque: Another iterative design pass on deque operations
- Adopt and embrace Drain and Producer to simplify moving data in and out of deques.
- Fully generalized core range replacement primitive using higher-order functions based around InputSpan and OutputSpan
2026-01-25 16:42:40 -08:00
Karoy Lorentey cda49ed5a8 Merge remote-tracking branch 'origin/main' into all-hands-on-deque
# Conflicts:
#	Sources/InternalCollectionsUtilities/UnsafeMutableBufferPointer+Extras.swift
2026-01-17 00:20:32 -08:00
Karoy Lorentey a617f5e2b1 Don’t use @unsafe/unsafe in code that needs to work on 6.1 2026-01-16 17:32:53 -08:00
Karoy Lorentey 7f7089eae6 Update Producer and Drain, fleshing them out a bit 2026-01-16 16:06:27 -08:00
Karoy Lorentey d1d757e425 [RigidDeque] Implement replacement operations 2026-01-08 17:25:21 -08:00
Karoy Lorentey 5943e6eb5c [RigidDeque] Flesh out insertions 2026-01-07 17:46:25 -08:00
Alejandro Alonso 3975774393 wip 2025-10-23 15:05:12 -07:00
Karoy Lorentey bb8d566833 Adopt package access modifier and get rid of gybbing 2025-09-29 11:56:14 -07:00