mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Encode small Characters as UTF-16
This takes care of the standard library portion, but we need a new BuiltinUTF16ExtendedGraphemeClusterLiteralConvertible protocol in order to fully recover the performance of character literals. Note that part of the character_literals.swift test is currently disabled. That will need to be fixed before we can merge this work.
This commit is contained in:
@@ -702,13 +702,11 @@ extension String.CharacterView : RangeReplaceableCollection {
|
||||
///
|
||||
/// - Parameter c: The character to append to the character view.
|
||||
public mutating func append(_ c: Character) {
|
||||
switch c._representation {
|
||||
case .small(let _63bits):
|
||||
let bytes = Character._smallValue(_63bits)
|
||||
_core.append(contentsOf: Character._SmallUTF16(bytes))
|
||||
case .large(_):
|
||||
_core.append(String(c)._core)
|
||||
if let c0 = c._smallUTF16 {
|
||||
_core.append(contentsOf: c0)
|
||||
return
|
||||
}
|
||||
_core.append(c._largeUTF16!)
|
||||
}
|
||||
|
||||
/// Appends the characters in the given sequence to the character view.
|
||||
|
||||
Reference in New Issue
Block a user