Commit Graph
785 Commits
Author SHA1 Message Date
Karoy Lorentey dc55a17401 Merge pull request #507 from viere1234/patch
[SortedCollections] Fix B-tree root reduction during element removal causing data loss
2025-08-17 21:32:30 -07:00
Brian Chang 21757b6add [BTree] Fix root reduction during element removal causing data loss
When removing elements from a B-tree, the root node could become empty while still having children. The previous code incorrectly called drop() which deallocated all children, causing massive data loss during removal operations.

This fix implements proper root reduction by moving the single remaining child out of the empty root, then safely dropping the now-empty parent node and promoting the extracted child to become the new root.

This fixes `test_modifySubscriptRemoval` in `SortedDictionaryTests`, so we re-enable SortedDictionary tests which now all pass.
2025-08-15 23:21:22 +08:00
Brian Chang e0b68624ba [BTree] Fix incorrect offset calculation in findAnyIndex
`findAnyIndex(forKey:)` miscomputed the global offset when a key was found in an internal B-tree node, due to missing child subtree counts in the calculation.
2025-08-13 13:43:18 +08:00
Karoy Lorentey e7ffe90ae7 Merge pull request #501 from faimin/main
Add the missing COLLECTIONS_SINGLE_MODULE when import InternalCollectionsUtils
2025-08-11 17:29:38 -07:00
Karoy Lorentey 990d4b30fb Merge pull request #502 from viere1234/main
[SortedSet] Fix subtreeCount inconsistency after remove at index
2025-08-11 17:29:25 -07:00
Tobias 8db0c6eb75 fix typo in init docs for Deque.swift 2025-08-07 10:29:59 +02:00
Brian Chang a98fbaba8b [SortedSet] Fix subtreeCount inconsistency after remove at index
Previously, when removing an element from a child node, the subtreeCount
of the current internal node wasn't updated, leading to incorrect counts.
2025-08-01 22:45:17 +08:00
faimin f6256df262 Add the missing macro condition when import InternalCollectionsUtilities 2025-07-30 14:44:22 +08:00
Christopher Thielen f44eabc30e Include DequeModule in the Foundation toolchain build 2025-07-22 15:58:24 -07:00
Tony Parker c883a1729a Add support for embedded Swift mode
Remove calls to `debugPrint` (which does not exist), and ifdef out support for `Codable` and `Reflection`.
2025-07-17 16:36:56 -07:00
Alex Azarov 9f68408a70 Update OrderedSet.swift
Make values immutable if they are never mutated in example usage docs.
2025-06-30 11:35:45 +02:00
Alex Azarov d7301b7278 Fix OrderedSet example usage 2025-06-29 16:48:57 +02:00
Karoy Lorentey 05ad8633a8 Merge branch 'release/1.2' 2025-06-24 15:06:25 -07:00
Karoy Lorentey fc411858ee [BigString] Speed up index distance calculations
This implements a roughly 40-45% improvement for distance measurements over `BigString`’s character and Unicode Scalar views.

Interestingly, we don’t see an improvement for UTF-16 views — I’m guessing this is due to String’s breadcrumbing. (And it will go away with the upcoming UTF8Span-ification of this type.)

The benchmarks I added only show an improvement for multi-chunk big string instances, but this is merely an artifact of the specific algorithm that is being measured — for single-chunk strings, the existing measurement method is already optimal, so the new heuristic never triggers for this particular payload.
2025-06-23 15:21:40 -07:00
Karoy Lorentey 65f99e3eff [BigString] Fix character indexing operations
BigString sometimes miscounted distances in its character view due to alignment issues. Resolve this by overhauling distance calculations in the character metric:

- Introduce a `prefixSize` function in `_StringMetric`, distinct from `distance`.
- In the metric-agnostic index distance algorithm, use `prefixCount` to avoid double-counting characters that cross (or end on) chunk boundaries.
- Simplify `_StringMetric.distance` by requiring that `start <= end`.
- Crucially, change character-index operations to start by rounding each input index down to the nearest character break.
2025-06-17 17:28:02 -07:00
Karoy Lorentey 4216d2ad1b Merge pull request #478 from ozumin/patch-1
fix comment for OrderedSet.appending(contentsOf:)
2025-05-21 09:24:42 -07:00
Karoy Lorentey 6819c6d149 Enable MemberImportVisibility and fix issues uncovered 2025-05-20 18:11:44 -07:00
Karoy Lorentey d4946c5dcb Remove obsolete language checks 2025-05-20 15:12:32 -07:00
Karoy Lorentey 0f73f0ace7 Merge branch 'release/1.2'
# Conflicts:
#	.github/workflows/pull_request.yml
#	.swiftci/5_10_ubuntu2204
#	.swiftci/5_7_ubuntu2204
#	.swiftci/5_8_ubuntu2204
#	.swiftci/5_9_ubuntu2204
#	.swiftci/nightly_6_0_macos
#	.swiftci/nightly_6_0_ubuntu2204
#	.swiftci/nightly_main_macos
#	.swiftci/nightly_main_ubuntu2204
2025-05-20 11:13:32 -07:00
Mizuo Nagayama 1812091001 fix comment for OrderedSet.appending(contentsOf:) 2025-05-20 18:38:06 +09:00
Karoy Lorentey 5e3a056312 Prerelease updates 2025-05-16 16:55:09 -07:00
Karoy Lorentey a09d7cdf45 Drop support for the Swift 5.9.* toolchains 2025-05-16 13:05:36 -07:00
Karoy Lorentey d5f3b81e69 [Heap] removeAll(where:): Fix exception safety 2025-05-16 00:25:57 -07:00
Dakshin Devanand 027b92153b Add Heap.removeAll(where:) 2025-05-16 00:25:42 -07:00
Karoy Lorentey 60746986d8 [Heap] Fix remaining tie break inconsistency in popMax 2025-05-16 00:25:35 -07:00
Karoy Lorentey 6950b7e77d [Heap] Follow the spelling of stdlib’s min/max; add note explaining expectations
The existing expressions had the same effect, but they used different operators (`<=` instead of `<` and `>` instead of `>=`). The distinction is usually irrelevant, but there is no reason not to just follow what the stdlib is doing exactly.
2025-05-16 00:25:18 -07:00
Evan Wilde 4467318e2f Use full module triple for swift modules
Install swiftmodules with the full module triple expected by the
compiler instead of attempting to compute the correct architecture name
in CMake.
2025-05-16 00:24:43 -07:00
3405691582andKaroy Lorentey 29cdb59bf9 Update Sources/HashTreeCollections/HashNode/_HashTreeStatistics.swift
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2025-05-16 00:21:38 -07:00
3405691582 8bbbe287c3 ManagedBuffer.capacity is unavailable on OpenBSD.
ManagedBuffer.capacity depends on malloc introspection (e.g.,
`malloc_size`), which is not available on this platform -- and is thus
marked as such.

Here, _HashNode.Storage is a ManagedBuffer. Thankfully, the uses of
.capacity are fairly limited: one for statistic purposes, which we just
completely omit on the platform, and the other, setting a minimum
capacity in the header by the buffer's .capacity; the alternative being
setting that minimum capacity directly.
2025-05-16 00:21:24 -07:00
Dakshin Devanand 0495c7b6a1 Make Heap._UnsafeHandle min/maxValue tie-breaker consistent with Swift.min/max 2025-05-16 00:19:24 -07:00
Peter Meyers 3fb4855e0e [OrderedSet] Add OrderedSet.appending(contentsOf:) 2025-05-16 00:16:00 -07:00
Karoy Lorentey dbc2866bb5 [Heap] removeAll(where:): Fix exception safety 2025-05-15 21:39:55 -07:00
Dakshin Devanand c7c38028cd Add Heap.removeAll(where:) 2025-05-15 21:39:50 -07:00
Karoy Lorentey ace6afa65b Merge pull request #455 from DakshinD/heap-max-func
Align Heap._UnsafeHandle min/maxValue tie-breaking with Swift.min/max
2025-05-15 21:08:49 -07:00
Karoy Lorentey 225159599d [Heap] Fix remaining tie break inconsistency in popMax 2025-05-15 17:34:16 -07:00
Karoy Lorentey d93a6ab8a1 [Heap] Follow the spelling of stdlib’s min/max; add note explaining expectations
The existing expressions had the same effect, but they used different operators (`<=` instead of `<` and `>` instead of `>=`). The distinction is usually irrelevant, but there is no reason not to just follow what the stdlib is doing exactly.
2025-05-15 17:30:25 -07:00
Karoy Lorentey e63f444a26 Merge pull request #456 from 3405691582/nocapacity
ManagedBuffer.capacity is unavailable on OpenBSD.
2025-05-15 14:57:30 -07:00
Karoy Lorentey 42fd02dd1a Merge pull request #452 from pm-dev/ordered-set-appending
[OrderedSet] Add `OrderedSet.appending(contentsOf:)`
2025-05-15 14:19:55 -07:00
Karoy Lorentey 0bd8dec08b Reimplement _specialize(_:for:) for the 5.9 stdlib 2025-05-14 16:40:25 -07:00
Evan Wilde a7fec81fc4 Use full module triple for swift modules
Install swiftmodules with the full module triple expected by the
compiler instead of attempting to compute the correct architecture name
in CMake.
2025-05-12 20:34:02 -07:00
3405691582andKaroy Lorentey 25509c0b88 Update Sources/HashTreeCollections/HashNode/_HashTreeStatistics.swift
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2025-05-02 17:04:54 -04:00
3405691582 9523b6a85d ManagedBuffer.capacity is unavailable on OpenBSD.
ManagedBuffer.capacity depends on malloc introspection (e.g.,
`malloc_size`), which is not available on this platform -- and is thus
marked as such.

Here, _HashNode.Storage is a ManagedBuffer. Thankfully, the uses of
.capacity are fairly limited: one for statistic purposes, which we just
completely omit on the platform, and the other, setting a minimum
capacity in the header by the buffer's .capacity; the alternative being
setting that minimum capacity directly.
2025-03-29 13:12:52 -04:00
Dakshin Devanand 5edd1be23c Make Heap._UnsafeHandle min/maxValue tie-breaker consistent with Swift.min/max 2025-03-08 10:08:39 -06:00
Peter Meyers e00243217e [OrderedSet] Add OrderedSet.appending(contentsOf:) 2025-02-20 15:34:04 -05:00
Karoy Lorentey 973459e875 Merge pull request #449 from lorentey/typo-fix-1.2
[1.2][OrderedDictionary] fix a typo
2025-02-06 17:57:28 -08:00
김봉균 1cb3ca50a6 fix typo 2025-02-06 17:54:37 -08:00
Fabrice de Gans 99db3179fc Change file names for toolchain module build
This also reverts 40adeb7, which seems to have been done in error.
2025-02-03 15:42:44 -08:00
Michael Chiu 40adeb7fd7 shouldnot install .swiftdoc as .swiftmodule 2025-01-27 15:13:00 -08:00
김봉균 4450b7c622 fix typo 2025-01-07 11:26:40 +09:00
Karoy Lorentey 2709b96947 Minor code style updates 2024-11-18 13:59:31 -08:00