mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] extendingOrTruncating: => truncatingIfNeeded:
This commit is contained in:
committed by
Max Moiseev
parent
d018ecccf5
commit
a5ff35cd41
@@ -44,11 +44,11 @@ where Encoding.EncodedScalar : RangeReplaceableCollection {
|
||||
// Non-ASCII, proceed to buffering mode.
|
||||
_buffer.append(codeUnit)
|
||||
} else if Encoding._isScalar(
|
||||
Encoding.CodeUnit(extendingOrTruncating: _buffer._storage)
|
||||
Encoding.CodeUnit(truncatingIfNeeded: _buffer._storage)
|
||||
) {
|
||||
// ASCII in _buffer. We don't refill the buffer so we can return
|
||||
// to bufferless mode once we've exhausted it.
|
||||
let codeUnit = Encoding.CodeUnit(extendingOrTruncating: _buffer._storage)
|
||||
let codeUnit = Encoding.CodeUnit(truncatingIfNeeded: _buffer._storage)
|
||||
_buffer.remove(at: _buffer.startIndex)
|
||||
return .valid(Encoding.EncodedScalar(CollectionOfOne(codeUnit)))
|
||||
}
|
||||
@@ -74,7 +74,7 @@ where Encoding.EncodedScalar : RangeReplaceableCollection {
|
||||
|
||||
_buffer._storage = UInt32(
|
||||
// widen to 64 bits so that we can empty the buffer in the 4-byte case
|
||||
extendingOrTruncating: UInt64(_buffer._storage) &>> scalarBitCount)
|
||||
truncatingIfNeeded: UInt64(_buffer._storage) &>> scalarBitCount)
|
||||
|
||||
_buffer._bitCount = _buffer._bitCount &- scalarBitCount
|
||||
|
||||
|
||||
Reference in New Issue
Block a user