Skip to content

Commit 8f65539

Browse files
author
Dave Abrahams
committed
encode(_:output:) => encode(_:sendingOutputTo processCodeUnit:)
1 parent 9ee14ee commit 8f65539

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

stdlib/public/core/String.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ extension String {
468468
Encoding: UnicodeCodec
469469
>(_ encoding: Encoding.Type) -> Int {
470470
var codeUnitCount = 0
471-
let output: (Encoding.CodeUnit) -> Void = { _ in codeUnitCount += 1 }
472-
self._encode(encoding, output: output)
471+
self._encode(encoding, sendingOutputTo: { _ in codeUnitCount += 1 })
473472
return codeUnitCount
474473
}
475474

@@ -482,9 +481,11 @@ extension String {
482481
// with unpaired surrogates
483482
func _encode<
484483
Encoding: UnicodeCodec
485-
>(_ encoding: Encoding.Type, output: @noescape (Encoding.CodeUnit) -> Void)
486-
{
487-
return _core.encode(encoding, output: output)
484+
>(
485+
_ encoding: Encoding.Type,
486+
sendingOutputTo processCodeUnit: @noescape (Encoding.CodeUnit) -> Void
487+
) {
488+
return _core.encode(encoding, sendingOutputTo: processCodeUnit)
488489
}
489490
}
490491

stdlib/public/core/StringCore.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,17 +329,17 @@ public struct _StringCore {
329329
}
330330

331331
/// Write the string, in the given encoding, to output.
332-
func encode<
333-
Encoding: UnicodeCodec
334-
>(_ encoding: Encoding.Type, output: @noescape (Encoding.CodeUnit) -> Void)
332+
func encode<Encoding: UnicodeCodec>(
333+
_ encoding: Encoding.Type,
334+
sendingOutputTo processCodeUnit: @noescape (Encoding.CodeUnit) -> Void)
335335
{
336336
if _fastPath(_baseAddress != nil) {
337337
if _fastPath(elementWidth == 1) {
338338
for x in UnsafeBufferPointer(
339339
start: UnsafeMutablePointer<UTF8.CodeUnit>(_baseAddress!),
340340
count: count
341341
) {
342-
Encoding.encode(UnicodeScalar(UInt32(x)), sendingOutputTo: output)
342+
Encoding.encode(UnicodeScalar(UInt32(x)), sendingOutputTo: processCodeUnit)
343343
}
344344
}
345345
else {
@@ -351,7 +351,7 @@ public struct _StringCore {
351351
from: UTF16.self,
352352
to: encoding,
353353
stoppingOnError: true,
354-
sendingOutputTo: output
354+
sendingOutputTo: processCodeUnit
355355
)
356356
_sanityCheck(!hadError, "Swift.String with native storage should not have unpaired surrogates")
357357
}
@@ -361,7 +361,7 @@ public struct _StringCore {
361361
_StringCore(
362362
_cocoaStringToContiguous(
363363
source: cocoaBuffer!, range: 0..<count, minimumCapacity: 0)
364-
).encode(encoding, output: output)
364+
).encode(encoding, sendingOutputTo: processCodeUnit)
365365
#else
366366
_sanityCheckFailure("encode: non-native string without objc runtime")
367367
#endif

0 commit comments

Comments
 (0)