Commit Graph
1801 Commits
Author SHA1 Message Date
David Nadoba 3a07388528 Add TemporaryArray: a stack-seeded, heap-spilling scratch array
TemporaryArray is a ~Copyable and ~Escapable dynamic array whose initial
storage is a borrowed buffer (most usefully a stack allocation vended by
withTemporaryArray(of:capacity:_:)) and which transparently spills over
into freshly allocated heap storage once it outgrows that seed buffer. As
long as the element count stays within a seed buffer that fit on the stack,
the array incurs no heap traffic at all.

Because it can hold a dependency on borrowed (stack) memory, the type is
non-escapable: instances cannot outlive the scope that provides their
initial buffer. Contents are lifted out into an owning container with
take(), which transfers the heap buffer in O(1) if the array has already
spilled, or moves the elements into a fresh UniqueArray otherwise.

The API mirrors UniqueArray (SE-0527), minus the pieces that don't apply
to a non-escapable scratch type (DynamicContainer, MutableContainer, and
RangeReplaceableContainer conformances plus the Drain-based consumer),
plus members unique to its borrow-then-spill design: take(), clone(), and
append(repeating:count:). The seed-buffer initializer is kept internal for
now, with withTemporaryArray as the sole entry point. Equatable/Hashable
and CustomStringConvertible/CustomDebugStringConvertible are implemented
as methods with FIXMEs to add the conformances once those protocols
support ~Copyable/~Escapable types.

The Collection/RangeReplaceable surface and container-protocol conformances
are gated behind the UnstableContainersPreview trait, mirroring UniqueArray;
the core API builds in the default configuration. DocC coverage is added for
the type and the withTemporaryArray entry point.
2026-07-09 15:16:13 -07:00
Karoy Lorentey 90f26545ce Merge pull request #673 from wjdtjq6/fix/doc-comment-typos
Fix typos in doc comments and a DocC article
2026-07-07 15:09:13 -07:00
Karoy Lorentey 638c62cd7b Merge pull request #674 from wjdtjq6/fix/superset-doc-comments
Fix superset set algebra doc comments
2026-07-07 15:08:52 -07:00
Karoy Lorentey 957813c2f4 Merge pull request #668 from inju2403/perf/orderedset-reverse-in-place
[OrderedCollections] OrderedSet.reverse(): update the hash table in place
2026-07-07 14:44:03 -07:00
Karoy Lorentey a7172d8dba Merge pull request #672 from apple/dependabot/github_actions/actions/checkout-7
Bump actions/checkout from 6 to 7
2026-07-07 14:43:21 -07:00
Karoy Lorentey 337e1411ef Merge pull request #679 from itej13/fix/inlinable-deinit-library-evolution
Fix @inlinable deinit incompatibility with library evolution (HashTree/Sorted storage)
2026-07-07 14:41:13 -07:00
wjdtjq6 62a08e503e docs: fix typos in doc comments and DocC article 2026-07-02 21:17:11 +09:00
Karoy Lorentey 6c12132eac Merge pull request #677 from apple/dependabot/github_actions/swiftlang/github-workflows/dot-github/workflows/swift_package_test.yml-0.0.12
Bump swiftlang/github-workflows/.github/workflows/swift_package_test.yml from 0.0.11 to 0.0.12
2026-07-01 14:36:57 -07:00
Karoy Lorentey b481404fa7 Merge pull request #678 from apple/dependabot/github_actions/swiftlang/github-workflows/dot-github/workflows/soundness.yml-0.0.12
Bump swiftlang/github-workflows/.github/workflows/soundness.yml from 0.0.11 to 0.0.12
2026-07-01 14:36:30 -07:00
Your NameandClaude Opus 4.8 259b4d52c2 Fix @inlinable deinit incompatibility with library evolution
The `Storage` classes in HashTreeCollections and SortedCollections mark
their `deinit` as `@inlinable` but lack `@_fixed_layout`. Under library
evolution (BUILD_LIBRARY_FOR_DISTRIBUTION=YES), Swift 6.2+ rejects this
with "deinitializer can only be '@inlinable' if the class is
'@_fixed_layout'", because inlining a deinit requires a known layout that
resilient mode deliberately hides.

This mirrors the existing fix already applied to the equivalent storage
classes in DequeModule (_DequeBuffer) and RopeModule (Rope._Storage). As
noted there, this does not make anything ABI stable -- these storage
classes are @usableFromInline internal and never part of the public ABI
surface -- it only lets these modules build with library evolution
enabled.

Fixes #676.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 16:15:00 +05:30
dependabot[bot] 075cdf29f8 Bump swiftlang/github-workflows/.github/workflows/soundness.yml
Bumps [swiftlang/github-workflows/.github/workflows/soundness.yml](https://github.com/swiftlang/github-workflows) from 0.0.11 to 0.0.12.
- [Release notes](https://github.com/swiftlang/github-workflows/releases)
- [Commits](https://github.com/swiftlang/github-workflows/compare/0.0.11...0.0.12)

---
updated-dependencies:
- dependency-name: swiftlang/github-workflows/.github/workflows/soundness.yml
  dependency-version: 0.0.12
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-29 06:06:53 +00:00
dependabot[bot] 6fd433f510 Bump swiftlang/github-workflows/.github/workflows/swift_package_test.yml
Bumps [swiftlang/github-workflows/.github/workflows/swift_package_test.yml](https://github.com/swiftlang/github-workflows) from 0.0.11 to 0.0.12.
- [Release notes](https://github.com/swiftlang/github-workflows/releases)
- [Commits](https://github.com/swiftlang/github-workflows/compare/0.0.11...0.0.12)

---
updated-dependencies:
- dependency-name: swiftlang/github-workflows/.github/workflows/swift_package_test.yml
  dependency-version: 0.0.12
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-29 06:06:52 +00:00
wjdtjq6 646274ed7c docs: fix superset set algebra comments 2026-06-23 13:21:36 +09:00
dependabot[bot] 3da62f0743 Bump actions/checkout from 6 to 7
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-22 06:07:30 +00:00
Karoy Lorentey f5b320c29f Merge pull request #657 from natecook1000/iterable 2026-06-17 19:08:16 -07:00
Karoy Lorentey 3d68fc1107 Clean up the UniqueBox/Ref/MutableRef situation
- UniqueBox is public API, so we cannot remove it in favor of the stdlib’s
- Remove Ref and MutableRef. Keep an internal _MutableRef to work around stdlib limitations.
2026-06-17 18:29:41 -07:00
Karoy Lorentey 51c9e4ead8 Fix IterableIteratorProtocol.map; add map2 and map3 with different throwing behavior 2026-06-17 18:24:03 -07:00
Karoy Lorentey 7c853751c6 Add IterableIteratorProtocol.mapError 2026-06-17 18:24:03 -07:00
Karoy Lorentey bced34defa Review error handling 2026-06-17 18:24:03 -07:00
Karoy Lorentey 85cdb77d25 Fix build issues 2026-06-17 16:17:36 -07:00
Karoy Lorentey 0dcc93b2c1 Merge pull request #670 from lorentey/define-6.4
Define SwiftStdlib 6.4 with actual version numbers
2026-06-17 15:33:16 -07:00
Karoy Lorentey f37fe8e662 Define SwiftStdlib 6.4 with actual version numbers 2026-06-17 14:57:06 -07:00
Karoy Lorentey c9b859dfda Don’t enable UnstableContainersPreview trait by default 2026-06-17 14:52:31 -07:00
Karoy Lorentey 816b887369 Update CMake and Xcode build configurations 2026-06-17 14:40:07 -07:00
Nate Cook c039a18a0e Switch to using stdlib Ref and UniqueBox 2026-06-17 14:27:29 -07:00
Nate Cook dca015d7e8 Align Iterable with proposal
Adds throwing and ~Escapable elements
2026-06-17 14:27:29 -07:00
Nate Cook 4bda43f4a9 Renaming BorrowingSequence_ to Iterable_ 2026-06-17 14:27:29 -07:00
Karoy Lorentey 232e6aeacf Merge pull request #667 from Azoy/setcapacity
[BasicContainers] Rename reallocate to setCapacity for Rigid and UniqueArray
2026-06-17 14:26:01 -07:00
Karoy Lorentey 9aca86f36b Update to reflect new name of expect{Rigid,Unique}ArrayContents 2026-06-17 13:58:54 -07:00
Karoy Lorentey 28e9d98a7e Fix deprecation warnings 2026-06-17 13:48:54 -07:00
Alejandro Alonso 06423d7329 Fix broken docs 2026-06-17 13:48:54 -07:00
Alejandro AlonsoandKaroy Lorentey 2a39308613 Update Sources/BasicContainers/UniqueArray/UniqueArray.swift
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2026-06-17 13:48:54 -07:00
Alejandro AlonsoandKaroy Lorentey eb5c24f71a Update Sources/BasicContainers/RigidArray/RigidArray.swift
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2026-06-17 13:48:54 -07:00
Alejandro AlonsoandKaroy Lorentey c6a1dabfd0 Update Sources/BasicContainers/RigidArray/RigidArray+Deprecated.swift
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2026-06-17 13:48:53 -07:00
Alejandro Alonso 6da58357a3 Rename reallocate to setCapacity for Rigid and UniqueArray
Update UniqueArray.swift

Update UniqueArray.swift
2026-06-17 13:48:53 -07:00
inju2403 a3baec1887 [Benchmark] Add OrderedSet<Int> reverse benchmark 2026-06-12 09:41:47 +09:00
inju2403 86ddbd9705 [OrderedCollections] OrderedSet.reverse(): update the hash table in place
Reversing an ordered set is a deterministic permutation: the element at offset `i` moves to offset `count - 1 - i`. Hash values are unaffected, so every element stays in its current bucket and only the stored offset needs to be flipped. `reverse()` was instead regenerating the whole hash table from scratch, rehashing every element -- exactly what the existing `// FIXME: Update hash table contents in place.` called out.

Replace `_regenerateHashTable()` with an in-place offset flip (`v -> count - 1 - v`) over the table's buckets, reusing the same bucket-walk idiom as `adjustContents` and `swapBucketValues`. This drops all hash recomputation and the table reallocation.
2026-06-12 08:57:42 +09:00
Karoy Lorentey af174fe447 Merge pull request #662 from sorinc03/fix/heap-node-tests-release
Run heap node tests in release
2026-06-09 15:03:37 -07:00
Karoy Lorentey a0cb0954ec Merge pull request #665 from lorentey/prerelease-cleanups
1.6.0 prerelease cleanups
1.6.0
2026-06-08 09:58:45 -07:00
Karoy Lorentey 9d0f2adb6b Update README 2026-06-05 18:50:16 -07:00
Karoy Lorentey f3ede2e378 Delete unused test source 2026-06-05 18:46:12 -07:00
Karoy Lorentey e31c04143e Update CMake & Xcode build configurations 2026-06-05 18:45:56 -07:00
Karoy Lorentey 5c8d97dccb Merge pull request #660 from apple/dn/ordered-set-move
[OrderedCollections] Add move operations
2026-06-05 17:45:16 -07:00
David Nadoba 72f074a23a [OrderedCollections] Use pre-removal destination index for move APIs 2026-06-05 17:05:03 -07:00
David Nadoba 5a6af29d55 [OrderedCollections] Refine move APIs and simplify no-op check 2026-06-05 14:44:22 -07:00
David Nadoba a83773321e [OrderedCollections] Rework move APIs and extend to OrderedDictionary
Reworks the relocation API and extends it to `OrderedDictionary`:

* Renames the index-range move to `moveSubrange(_:to:)` (with a
  `RangeExpression` overload) and the by-value move to `move(contentsOf:to:)`,
  matching the conventions of `removeSubrange`/`insert(_:at:)`. Adds
  `move(fromIndices:to:)`, which takes the source indices directly.
* Factors the element rearrangement into generic
  `UnsafeMutableBufferPointer` operations (rotation / rotation+permutation /
  scatter) so `OrderedDictionary` relocates its keys and values in lockstep
  through the same code, adding only the parallel value move; the hash-table
  maintenance stays entirely in `OrderedSet`.
* The hot path runs in O(*d* + *k*) and falls back to O(`count`) for large
  moves; bucket maintenance chooses targeted updates or a full rebuild by the
  same threshold.
* `move(contentsOf:to:)` ignores elements/keys that aren't present; duplicate
  members are detected and trap.

Adds tests (exhaustive hash-table integrity, value alignment under lifetime
tracking) and move benchmarks for both types.
2026-06-04 22:33:54 -07:00
Sorin Cioban bdd6b79403 Use package access for heap test helper 2026-06-04 10:18:09 +01:00
Karoy Lorentey 9ade2f7ba3 Merge pull request #664 from lorentey/benchmark-updates
Small benchmarking improvements
2026-06-02 18:13:55 -07:00
Karoy Lorentey c86ed20fc1 [Benchmark] Shareable(Set|Dictionary)Benchmarks → Tree$1Benchmarks 2026-06-02 17:57:49 -07:00
Karoy Lorentey b78086e6df [Benchmark] Resolve warnings under Swift 6.4 2026-06-02 17:48:22 -07:00