Skip to content

[gardening][Overlay] Use isEmpty in Data.swift #15674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stdlib/public/SDK/Foundation/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ public final class _DataStorage {
}

public func withInteriorPointerReference<T>(_ range: Range<Int>, _ work: (NSData) throws -> T) rethrows -> T {
if range.count == 0 {
if range.isEmpty {
return try work(NSData()) // zero length data can be optimized as a singleton
}

Expand Down Expand Up @@ -886,7 +886,7 @@ public final class _DataStorage {
}

public func bridgedReference(_ range: Range<Int>) -> NSData {
if range.count == 0 {
if range.isEmpty {
return NSData() // zero length data can be optimized as a singleton
}

Expand Down Expand Up @@ -1464,7 +1464,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
/// - parameter buffer: The buffer of bytes to append. The size is calculated from `SourceType` and `buffer.count`.
@inline(__always)
public mutating func append<SourceType>(_ buffer : UnsafeBufferPointer<SourceType>) {
if buffer.count == 0 { return }
if buffer.isEmpty { return }
if !isKnownUniquelyReferenced(&_backing) {
_backing = _backing.mutableCopy(_sliceRange)
}
Expand Down Expand Up @@ -1588,7 +1588,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
@inline(__always)
public func subdata(in range: Range<Index>) -> Data {
_validateRange(range)
if count == 0 {
if isEmpty {
return Data()
}
return _backing.subdata(in: range)
Expand Down