Skip to content

Commit e287c30

Browse files
authored
Merge pull request #13314 from ikesyo/optional-binding
2 parents 8bbe4d2 + 5682993 commit e287c30

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ public final class _DataStorage {
334334
let tryCalloc = (origLength == 0 || (newLength / origLength) >= 4)
335335
if allocateCleared && tryCalloc {
336336
newBytes = _DataStorage.allocate(newCapacity, true)
337-
if newBytes != nil {
338-
_DataStorage.move(newBytes!, _bytes!, origLength)
337+
if let newBytes = newBytes {
338+
_DataStorage.move(newBytes, _bytes!, origLength)
339339
_freeBytes()
340340
}
341341
}
@@ -344,8 +344,8 @@ public final class _DataStorage {
344344
allocateCleared = false
345345
if _deallocator != nil {
346346
newBytes = _DataStorage.allocate(newCapacity, true)
347-
if newBytes != nil {
348-
_DataStorage.move(newBytes!, _bytes!, origLength)
347+
if let newBytes = newBytes {
348+
_DataStorage.move(newBytes, _bytes!, origLength)
349349
_freeBytes()
350350
_deallocator = nil
351351
}
@@ -360,8 +360,8 @@ public final class _DataStorage {
360360
allocateCleared = clear && _DataStorage.shouldAllocateCleared(newCapacity)
361361
if allocateCleared && tryCalloc {
362362
newBytes = _DataStorage.allocate(newCapacity, true)
363-
if newBytes != nil {
364-
_DataStorage.move(newBytes!, _bytes!, origLength)
363+
if let newBytes = newBytes {
364+
_DataStorage.move(newBytes, _bytes!, origLength)
365365
_freeBytes()
366366
}
367367
}
@@ -610,8 +610,8 @@ public final class _DataStorage {
610610
memmove(mutableBytes! + start + replacementLength, mutableBytes! + start + length, currentLength - start - length)
611611
}
612612
if replacementLength != 0 {
613-
if replacementBytes != nil {
614-
memmove(mutableBytes! + start, replacementBytes!, replacementLength)
613+
if let replacementBytes = replacementBytes {
614+
memmove(mutableBytes! + start, replacementBytes, replacementLength)
615615
} else {
616616
memset(mutableBytes! + start, 0, replacementLength)
617617
}

stdlib/public/SDK/Foundation/NSStringAPI.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,8 +1471,8 @@ extension StringProtocol where Index == String.Index {
14711471
tokenRanges: $0) as NSArray
14721472
}
14731473

1474-
if nsTokenRanges != nil {
1475-
tokenRanges?.pointee = (nsTokenRanges! as [AnyObject]).map {
1474+
if let nsTokenRanges = nsTokenRanges {
1475+
tokenRanges?.pointee = (nsTokenRanges as [AnyObject]).map {
14761476
self._range($0.rangeValue)
14771477
}
14781478
}

0 commit comments

Comments
 (0)