mirror of
https://github.com/apple/swift-collections
synced 2026-11-30 05:18:44 +00:00
Implement path caching in indices
This commit is contained in:
18 files changed
+410
-426
No files matched your search
@@ -14,14 +14,13 @@
|
||||
@available(macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4, *)
|
||||
extension _BString.Chunk {
|
||||
/// UTF-16 index lookup.
|
||||
func index(at utf8Offset: Int, utf16Delta: Int) -> String.Index {
|
||||
func index(at utf8Offset: Int, utf16TrailingSurrogate: Bool) -> String.Index {
|
||||
var index = string._utf8Index(at: utf8Offset)
|
||||
if
|
||||
utf16Delta != 0,
|
||||
utf16TrailingSurrogate,
|
||||
index < string.endIndex,
|
||||
string.utf8[index]._isUTF8NonBMPLeadingCodeUnit
|
||||
{
|
||||
assert(utf16Delta == 1)
|
||||
index = string.utf16.index(after: index)
|
||||
}
|
||||
return index
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
extension _BString {
|
||||
struct Chunk {
|
||||
typealias Slice = (string: Substring, characters: Int, prefix: Int, suffix: Int)
|
||||
typealias Path = _BString.Path
|
||||
|
||||
var string: String
|
||||
var counts: Counts
|
||||
|
||||
Reference in new issue
Block a user