Commit Graph
31 Commits
Author SHA1 Message Date
Karoy Lorentey cffcd517a2 BigString: Start modernizing 2023-03-20 13:12:13 -07:00
Karoy Lorentey 6a7f53c3da _BString: Add conversion initializers from all views 2023-03-20 13:12:12 -07:00
Karoy Lorentey 03d7c43c22 _BString: Add index rounding methods to all views 2023-03-20 13:12:12 -07:00
Karoy Lorentey 258d22947c _BString: Review Equatable implementations 2023-03-20 13:12:12 -07:00
Karoy Lorentey abf5dfd260 _BSubstring: Conform to Comparable 2023-03-20 13:12:12 -07:00
Karoy Lorentey 1182398068 _BString: Give each view a custom iterator by hooking up the existing implementations 2023-03-20 13:12:12 -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 a10439bc32 _BString, _BSubstring: Merge character views into top-level types. Add RangeReplaceableCollection conformances.
This emulates the standard String.
2023-03-20 13:12:12 -07:00
Karoy Lorentey eda72e344f _BString: Fix character index rounding; use it when accessing character data
Oops, `_BString.subscript(character:)` failed to round down to a character boundary before trying to access the addressed character. It also resolved the index with `preferEnd` set to true, which isn’t what we actually want.
2023-03-20 13:12:12 -07:00
Karoy Lorentey e0f8305a99 _BString.hashUTF8(into:from:end:): Fix typo
- The original code accidentally used `start` instead of `end` to normalize the end of the range, so it did not actually hash any actual string contents.
- While we’re here, extract the task of iterating over substring chunks into a reusable standalone method.
2023-03-20 13:12:11 -07:00
Karoy Lorentey 28727f7c56 _BString: Implement views
Having all core functionality exposed by the top-level type is not a bad idea; unfortunately substrings are tricky to get right, so it’s better to implement that out of the box.
2023-03-20 13:12:11 -07:00
Karoy Lorentey b5e3bee275 _BString.Index: Add alignment bits
Use them to speed up index rounding.
(And, somewhat questionably, subscripting.)
2023-03-20 13:12:11 -07:00
Karoy Lorentey 7444bb24cb _CharacterRecognizer don’t use conformances that aren’t in the Xcode 14.3 beta 2023-03-20 13:12:11 -07:00
Karoy Lorentey 4f2024c44d _BString: Elaborate on the swift 5.8 dependency a bit 2023-03-20 13:12:11 -07:00
Karoy Lorentey 85a43d9ac6 _BString: Add a substring types and actual collection views
This is more of a technical workaround, as it allows
running generic algorithms on these things. That said,
we could embrace this in general, and sink the
`utf8Index(after:)`, `characterIndex(before:)` etc
function down into these views, instead of having them
on the top level.
2023-03-20 13:12:11 -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 9bbdfdc497 Cosmetic updates to _BString.CharacterIterator 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 8f48c3ae37 More assorted bug fixes and refinements 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 8c8cb5622b Restrict BIgString and _BString to Swift 5.8 and macOS 13.3 /iOS 16.4/etc
These types heavily rely on stdlib functionality that ships in
Swift 5.8; they do not run correctly on earlier releases.
2023-03-20 13:12:09 -07:00
Karoy Lorentey 283d4071bc Assorted bug fixes and refinements 2023-03-20 13:12:08 -07:00
Karoy Lorentey 96aebb90b7 Fix initializing a String from a _BString slice 2023-03-20 13:12:08 -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