mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Stay in vectors longer before doing a horizontal sum
This commit is contained in:
@@ -533,14 +533,18 @@ extension String.UTF16View {
|
||||
//Find the number of continuations (0b10xxxxxx)
|
||||
let sValue = Builtin.loadRaw(readPtr._rawValue) as S
|
||||
let continuations = S.zero.replacing(with: S.one, where: sValue .< -65 + 1)
|
||||
let continuationCount = Int(continuations.wrappedSum())
|
||||
|
||||
//Find the number of 4 byte code points (0b11110xxx)
|
||||
let uValue = Builtin.loadRaw(readPtr._rawValue) as U
|
||||
let fourBytes = U.zero.replacing(with: U.one, where: uValue .>= 0b11110000)
|
||||
let fourByteCount = Int(fourBytes.wrappedSum())
|
||||
|
||||
utf16Count &+= (U.scalarCount - continuationCount) + fourByteCount
|
||||
let fourBytes = S.zero.replacing(
|
||||
with: S.one,
|
||||
where: unsafeBitCast(
|
||||
uValue .>= 0b11110000,
|
||||
to: SIMDMask<S.MaskStorage>.self
|
||||
)
|
||||
)
|
||||
|
||||
utf16Count &+= U.scalarCount + Int((fourBytes &- continuations).wrappedSum())
|
||||
|
||||
readPtr += MemoryLayout<U>.stride
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user