Skip to content

Commit 451d46b

Browse files
committed
---
yaml --- r: 202134 b: refs/heads/tensorflow c: 47deadc h: refs/heads/master
1 parent 4dbef3a commit 451d46b

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
821821
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
822822
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
823823
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
824-
refs/heads/tensorflow: 5a7d7d392922a2bb949bf4960debaa669e784fb8
824+
refs/heads/tensorflow: 47deadc2fb3526b1720bbb99afd5636430238088
825825
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
826826
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
827827
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/stdlib/public/core/UnicodeScalarProperties.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,9 @@ extension Unicode.Scalar {
2424
// We convert the value to the underlying UChar32 type here and store it
2525
// in that form to make calling the ICU APIs cleaner below.
2626
self._value = __swift_stdlib_UChar32(bitPattern: _scalar._value)
27-
28-
// Likewise, we cache the UTF-16 encoding of the scalar for a few of the
29-
// properties that require treating it like a string (e.g., case
30-
// mappings).
31-
let utf16 = _scalar.utf16
32-
self._utf16Length = utf16.count
33-
self._utf16 = (utf16[0], _utf16Length > 1 ? utf16[1] : 0)
3427
}
3528

3629
internal var _value: __swift_stdlib_UChar32
37-
internal var _utf16: (UTF16.CodeUnit, UTF16.CodeUnit)
38-
internal var _utf16Length: Int
3930
}
4031

4132
/// A value that provides access to properties of the Unicode scalar that are
@@ -1036,6 +1027,15 @@ extension Unicode.Scalar.Properties {
10361027

10371028
extension Unicode.Scalar.Properties {
10381029

1030+
/// The UTF-16 encoding of the scalar, represented as a tuple of 2 elements.
1031+
///
1032+
/// If the scalar only encodes to one code unit, the second element is zero.
1033+
@_transparent
1034+
internal var _utf16CodeUnits: (UTF16.CodeUnit, UTF16.CodeUnit) {
1035+
let utf16 = UnicodeScalar(UInt32(_value))!.utf16
1036+
return (utf16[0], utf16.count > 1 ? utf16[1] : 0)
1037+
}
1038+
10391039
// The type of ICU case conversion functions.
10401040
internal typealias _U_StrToX = (
10411041
/* dest */ UnsafeMutablePointer<__swift_stdlib_UChar>,
@@ -1053,16 +1053,17 @@ extension Unicode.Scalar.Properties {
10531053
/// all current case mappings. In the event more space is needed, it will be
10541054
/// allocated on the heap.
10551055
internal func _applyMapping(_ u_strTo: _U_StrToX) -> String {
1056+
let utf16Length = UnicodeScalar(UInt32(_value))!.utf16.count
1057+
var utf16 = _utf16CodeUnits
10561058
var scratchBuffer = _Normalization._SegmentOutputBuffer(allZeros: ())
10571059
let count = scratchBuffer.withUnsafeMutableBufferPointer { bufPtr -> Int in
1058-
var utf16 = _utf16
10591060
return withUnsafePointer(to: &utf16.0) { utf16Pointer in
10601061
var err = __swift_stdlib_U_ZERO_ERROR
10611062
let correctSize = u_strTo(
10621063
bufPtr.baseAddress._unsafelyUnwrappedUnchecked,
10631064
Int32(bufPtr.count),
10641065
utf16Pointer,
1065-
Int32(_utf16Length),
1066+
Int32(utf16Length),
10661067
"",
10671068
&err)
10681069
guard err.isSuccess ||
@@ -1078,14 +1079,13 @@ extension Unicode.Scalar.Properties {
10781079
}
10791080
var array = Array<UInt16>(repeating: 0, count: count)
10801081
array.withUnsafeMutableBufferPointer { bufPtr in
1081-
var utf16 = _utf16
10821082
withUnsafePointer(to: &utf16.0) { utf16Pointer in
10831083
var err = __swift_stdlib_U_ZERO_ERROR
10841084
let correctSize = u_strTo(
10851085
bufPtr.baseAddress._unsafelyUnwrappedUnchecked,
10861086
Int32(bufPtr.count),
10871087
utf16Pointer,
1088-
Int32(_utf16Length),
1088+
Int32(utf16Length),
10891089
"",
10901090
&err)
10911091
guard err.isSuccess else {

0 commit comments

Comments
 (0)