Commit Graph
44 Commits
Author SHA1 Message Date
Karoy Lorentey 1c69635852 Add SPDX-License-Identifier tags 2026-03-05 19:39:24 -08:00
Karoy Lorentey d9b09ecde8 Update copyright dates 2026-03-05 19:39:20 -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 bc9c63ae41 [Rope] Highlight CoW issue in Swift 6 mode 2025-08-17 13:33:40 -07:00
Karoy Lorentey e4cd17cc53 Remove support code for outdated toolchains 2024-09-25 14:14:48 -07:00
Karoy Lorentey a0b839d7de [Rope] Fix copy-on-write violation in Rope.join
Rope.join has a logic error where it fails to properly ensure uniqueness of child node references before zipping the two b-trees together.

rdar://128450202
2024-05-31 17:12:07 -07:00
Karoy Lorentey 35d5746117 Rename _CollectionsUtilities to InternalCollectionsUtilities
We are forced to do this due to an Xcode issue (#364) with underscored module names.

This module remains unstable, despite the removal of the underscore. Directly importing it from outside the package remains unsupported. This module and/or its entire contents may go away or change in incompatible ways in any future swift-collections release.
2024-05-29 14:00:13 -07:00
Dimitris Apostolou 7539583245 Fix typos
# Conflicts:
#	Sources/SortedCollections/BTree/_BTree+BidirectionalCollection.swift
#	Sources/SortedCollections/BTree/_BTree+UnsafeCursor.swift
#	Sources/SortedCollections/BTree/_BTree.Builder.swift
#	Sources/SortedCollections/BTree/_BTree.swift
#	Sources/SortedCollections/BTree/_Node.Splinter.swift
#	Sources/SortedCollections/BTree/_Node.Storage.swift
#	Sources/SortedCollections/BTree/_Node.UnsafeHandle+Insertion.swift
#	Sources/SortedCollections/BTree/_Node.swift
#	Tests/SortedCollectionsTests/BTree/Node+Join Tests.swift
2024-02-06 15:52:26 -08:00
Karoy Lorentey ffa4a58bc1 Update remaining copyright notices 2024-02-02 16:20:22 -08:00
Karoy Lorentey 5bce3c9ceb [RopeModule] Adopt _specialize and extend adoption of modern generic decl syntax 2024-02-02 16:20:21 -08:00
Karoy Lorentey 33f23b6a06 [RopeModule] Remove unnecessary typealiases
These render the emitted .swiftinterface unusable when the module is built with library evolution enabled.
2023-10-18 17:57:00 -07:00
Karoy Lorentey de2c8a9086 [RopeModule] Allow building with library evolution enabled
rdar://114659667
2023-10-18 14:22:12 -07:00
Karoy Lorentey 03e7f0c401 [Rope] Fix find to return a zero remainder for the end position 2023-06-02 17:37:30 -07:00
Karoy Lorentey 03c9ef743a [Rope] Fix crash when calling replaceSubrange/removeSubrange on an empty rope 2023-06-01 20:24:24 -07:00
Karoy Lorentey dce7b156e7 [Rope] remove(at:): Fix assertion when removing the last item creates a deficiency 2023-04-17 17:20:07 -07:00
Karoy Lorentey b0fe7ca8ba [Rope] replaceSubrange: take a sequence, not a collection 2023-04-14 14:38:30 -07:00
Karoy Lorentey 3fa52c48de [Rope] Add remove(at:), remove(at:in:) variants that preserve the position 2023-04-13 19:36:09 -07:00
Karoy Lorentey 1925ed3001 [Rope] update(at:by:): Invalidate indices
Calling this function is supposed to invalidate all indices other than
the input index — so let’s do that.
2023-04-12 17:55:19 -07:00
Karoy Lorentey cead2b3d64 [Rope] index(_:offsetBy:in:preferEnd:) fix result tuple labeling
This renames `remainder` to `remaining`, restoring API consistency.
2023-04-12 17:54:13 -07:00
Karoy Lorentey bc21b90ff1 [Rope] Minor usability fixes and API additions 2023-04-12 17:53:04 -07:00
Karoy Lorentey 4afdfe4da2 [Rope] Flesh out docs a little bit
Rope remains woefully undocumented, and I suspect its abstraction
level isn’t right for general use, but let’s see if writing up some
documentation for it will make it a bit more accessible.
2023-04-12 17:52:19 -07:00
Karoy Lorentey 900e7851ab Merge pull request #271 from lorentey/fix-rope-sendable
Rope: Fix `Sendable` conformance
2023-04-10 17:43:23 -07:00
Karoy Lorentey 454c84b5e4 Make most of Rope inlinable 2023-04-10 16:56:30 -07:00
Karoy Lorentey 9c3328e235 Rope: Fix Sendable conformance
`Rope._Node` wasn’t declared `Sendable`, which triggered valid warnings.
2023-04-10 16:45:28 -07:00
Karoy Lorentey cbab9e3737 Introduce COLLECTIONS_SINGLE_MODULE condition 2023-03-21 18:42:33 -07:00
Karoy Lorentey 8394ea7575 Clean up test definitions 2023-03-21 01:30:03 -07:00
Karoy Lorentey 28010b2f6c Use COLLECTIONS_INTERNAL_CHECKS 2023-03-21 01:28:13 -07:00
Karoy Lorentey ad82bc3f80 Naming review 2023-03-21 01:21:43 -07:00
Karoy Lorentey dc23b4d621 Rope: Fix splitting logic after insertions
I changed the minNodeSize formula to match with the B-tree definition, but I failed to match the insertion logic, so it left trees with undersized nodes. D’oh!
2023-03-21 01:06:53 -07:00
Karoy Lorentey 6f3f19d1c5 _Rope → Rope 2023-03-20 23:49:57 -07:00
Karoy Lorentey b022b7fee5 Make _BString and _Rope public 2023-03-20 18:36:37 -07:00
Karoy Lorentey 535b8b8562 Fix compatbility with Swift toolchains below 5.8 2023-03-20 14:25:28 -07:00
Karoy Lorentey 59b5c634d0 _Rope.UnsafeHandle._removeChild(at:): Fix buffer overflow uncovered by ASan 2023-03-20 13:12:12 -07:00
Karoy Lorentey fe54fdaa47 More fixes. 2023-03-20 13:12:10 -07:00
Karoy Lorentey 605e45b9b9 _BString: Additional fixes and new functionality
- New methods for rounding up indices
- Sendable conformances
- Fix UTF-16 strings sometimes leaking into chunks
- Iterator improvements / rewrites, incl. a chunked UTF-8
   buffer iterator.
- Support for comparing and hashing UTF-8 slices.
2023-03-20 13:12:10 -07:00
Karoy Lorentey 79bdcb66eb Implement path caching in indices 2023-03-20 13:12:10 -07:00
Karoy Lorentey 575937f6ff Remove _Rope._leaf(at:) 2023-03-20 13:12:09 -07:00
Karoy Lorentey b6f9d83c60 Replace Rope iterator with indices in most index-like use cases 2023-03-20 13:12:09 -07:00
Karoy Lorentey 3cc5a3888a _Rope: Add a leaf node reference to indices. Implement explicit index invalidation 2023-03-20 13:12:09 -07:00
Karoy Lorentey 8c1740ad28 _Rope.Index: Merge height into UInt64 storage.
This leaves 56 bits for path data, which should still be plenty.
(We want to allow big strings to grow to 2^48 UTF-8 code units, to
match the standard String; however, there is no practical need to
support any more, and even that is a stretch.)

Add tests to verify that the tree capacity matches expectations
in Release builds. (In Debug builds, we limit the maximum node size,
which drastically reduces capacity. This is okay.)
2023-03-20 13:12:09 -07:00
Karoy Lorentey 67a149da6a _BString: Set better max node size in Release builds
Also, adjust minimum node size calculation to match classic B-trees.
2023-03-20 13:12:09 -07:00
Karoy Lorentey 18aa309f75 Generalize some _BString iterators 2023-03-20 13:12:07 -07:00
Karoy Lorentey eabd941799 Add some operations taking subsequences 2023-03-20 13:12:07 -07:00
Karoy Lorentey 150a165d73 Add experimental rope implementation 2023-03-20 13:11:21 -07:00