[gardening] Avoid fallthrough where appropriate (for readability/understandability)

This commit is contained in:
Sho Ikeda
2019-05-26 09:49:44 +09:00
parent b088acb66e
commit c1bb945124
2 changed files with 15 additions and 23 deletions

View File

@@ -72,9 +72,8 @@ extension _AbstractStringStorage {
_ outputPtr: UnsafeMutablePointer<UInt8>, _ maxLength: Int, _ encoding: UInt
) -> Int8 {
switch (encoding, isASCII) {
case (_cocoaASCIIEncoding, true):
fallthrough
case (_cocoaUTF8Encoding, _):
case (_cocoaASCIIEncoding, true),
(_cocoaUTF8Encoding, _):
guard maxLength >= count + 1 else { return 0 }
outputPtr.initialize(from: start, count: count)
outputPtr[count] = 0
@@ -88,9 +87,8 @@ extension _AbstractStringStorage {
@_effects(readonly)
internal func _cString(encoding: UInt) -> UnsafePointer<UInt8>? {
switch (encoding, isASCII) {
case (_cocoaASCIIEncoding, true):
fallthrough
case (_cocoaUTF8Encoding, _):
case (_cocoaASCIIEncoding, true),
(_cocoaUTF8Encoding, _):
return start
default:
return _cocoaCStringUsingEncodingTrampoline(self, encoding)