Skip to content

Commit 160f7aa

Browse files
cburrowsthomasvl
authored andcommitted
Stop using Internal.emptyData in source
1 parent 0f984da commit 160f7aa

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

Sources/SwiftProtobuf/AnyMessageStorage.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ internal class AnyMessageStorage {
100100
do {
101101
return try message.serializedData(partial: true)
102102
} catch {
103-
return Internal.emptyData
103+
return Data()
104104
}
105105
case .contentJSON(let contentJSON, let options):
106106
guard let messageType = Google_Protobuf_Any.messageType(forTypeURL: _typeURL) else {
107-
return Internal.emptyData
107+
return Data()
108108
}
109109
do {
110110
let m = try unpack(contentJSON: contentJSON,
@@ -113,7 +113,7 @@ internal class AnyMessageStorage {
113113
as: messageType)
114114
return try m.serializedData(partial: true)
115115
} catch {
116-
return Internal.emptyData
116+
return Data()
117117
}
118118
}
119119
}
@@ -135,7 +135,7 @@ internal class AnyMessageStorage {
135135
// parsed JSON with the @type removed and the decoding options.
136136
case contentJSON(Data, JSONDecodingOptions)
137137
}
138-
var state: InternalState = .binary(Internal.emptyData)
138+
var state: InternalState = .binary(Data())
139139

140140
static let defaultInstance = AnyMessageStorage()
141141

@@ -445,7 +445,7 @@ extension AnyMessageStorage {
445445
try decoder.scanner.skipRequiredObjectStart()
446446
// Reset state
447447
_typeURL = String()
448-
state = .binary(Internal.emptyData)
448+
state = .binary(Data())
449449
if decoder.scanner.skipOptionalObjectEnd() {
450450
return
451451
}

Sources/SwiftProtobuf/FieldTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public struct ProtobufString: FieldType, MapKeyType, MapValueType {
393393
///
394394
public struct ProtobufBytes: FieldType, MapValueType {
395395
public typealias BaseType = Data
396-
public static var proto3DefaultValue: Data {return Internal.emptyData}
396+
public static var proto3DefaultValue: Data {return Data()}
397397
public static func decodeSingular<D: Decoder>(value: inout BaseType?, from decoder: inout D) throws {
398398
try decoder.decodeSingularBytesField(value: &value)
399399
}

Sources/SwiftProtobuf/JSONDecoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ internal struct JSONDecoder: Decoder {
434434

435435
mutating func decodeSingularBytesField(value: inout Data) throws {
436436
if scanner.skipOptionalNull() {
437-
value = Internal.emptyData
437+
value = Data()
438438
return
439439
}
440440
value = try scanner.nextBytesValue()

Sources/SwiftProtobuf/TextFormatEncodingVisitor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ internal struct TextFormatEncodingVisitor: Visitor {
156156
encoder.endRegularField()
157157
case .lengthDelimited:
158158
encoder.emitFieldNumber(number: tag.fieldNumber)
159-
var bytes = Internal.emptyData
159+
var bytes = Data()
160160
try decoder.decodeSingularBytesField(value: &bytes)
161161
bytes.withUnsafeBytes { (body: UnsafeRawBufferPointer) -> () in
162162
if let baseAddress = body.baseAddress, body.count > 0 {

Sources/SwiftProtobuf/UnknownStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Foundation
2424
public struct UnknownStorage: Equatable {
2525
/// The raw protocol buffer binary-encoded bytes that represent the unknown
2626
/// fields of a decoded message.
27-
public private(set) var data = Internal.emptyData
27+
public private(set) var data = Data()
2828

2929
#if !swift(>=4.1)
3030
public static func ==(lhs: UnknownStorage, rhs: UnknownStorage) -> Bool {

Sources/protoc-gen-swift/Descriptor+Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ extension FieldDescriptor {
211211
switch type {
212212
case .bool: return "false"
213213
case .string: return "String()"
214-
case .bytes: return "\(SwiftProtobufInfo.name).Internal.emptyData"
214+
case .bytes: return "Data()"
215215
case .group, .message:
216216
return namer.fullName(message: messageType) + "()"
217217
case .enum:

Sources/protoc-gen-swift/StringUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func trimWhitespace(_ s: String) -> String {
6262
/// \n\r\t\\\'\" and three-digit octal escapes but nothing else.
6363
func escapedToDataLiteral(_ s: String) -> String {
6464
if s.isEmpty {
65-
return "\(SwiftProtobufInfo.name).Internal.emptyData"
65+
return "Data()"
6666
}
6767
var out = "Data(["
6868
var separator = ""

0 commit comments

Comments
 (0)