Skip to content

Commit 36d5b6e

Browse files
committed
Formatting
1 parent b659cdf commit 36d5b6e

File tree

6 files changed

+60
-61
lines changed

6 files changed

+60
-61
lines changed

Sources/SwiftProtobuf/AsyncMessageSequence.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public struct AsyncMessageSequence<
125125
if (shift > 0) {
126126
// The stream has ended inside a varint.
127127
iterator = nil
128-
throw BinaryDelimited.Error.truncated
128+
throw BinaryDelimited.Error.truncated
129129
}
130130
return nil // End of stream reached.
131131
}
@@ -175,7 +175,7 @@ public struct AsyncMessageSequence<
175175
}
176176
guard messageSize <= UInt64(0x7fffffff) else {
177177
iterator = nil
178-
throw SwiftProtobufError.BinaryDecoding.tooLarge()
178+
throw SwiftProtobufError.BinaryDecoding.tooLarge()
179179
}
180180
if messageSize == 0 {
181181
return try M(

Sources/SwiftProtobuf/BinaryDecoder.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ internal struct BinaryDecoder: Decoder {
890890
try message.decodeMessage(decoder: &self)
891891
decrementRecursionDepth()
892892
guard complete else {
893-
throw BinaryDecodingError.trailingGarbage
893+
throw BinaryDecodingError.trailingGarbage
894894
}
895895
if let unknownData = unknownData {
896896
message.unknownFields.append(protobufData: unknownData)
@@ -1125,7 +1125,7 @@ internal struct BinaryDecoder: Decoder {
11251125
break
11261126

11271127
case .malformed:
1128-
throw BinaryDecodingError.malformedProtobuf
1128+
throw BinaryDecodingError.malformedProtobuf
11291129
}
11301130

11311131
assert(recursionBudget == subDecoder.recursionBudget)
@@ -1424,12 +1424,12 @@ internal struct BinaryDecoder: Decoder {
14241424
// that is length delimited on the wire, so the spec would imply
14251425
// the limit still applies.
14261426
guard length < 0x7fffffff else {
1427-
// Reuse existing error to avoid breaking change of changing thrown error
1428-
throw BinaryDecodingError.malformedProtobuf
1427+
// Reuse existing error to avoid breaking change of changing thrown error
1428+
throw BinaryDecodingError.malformedProtobuf
14291429
}
14301430

14311431
guard length <= UInt64(available) else {
1432-
throw BinaryDecodingError.truncated
1432+
throw BinaryDecodingError.truncated
14331433
}
14341434

14351435
count = Int(length)

Sources/SwiftProtobuf/Google_Protobuf_Duration+Extensions.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private func parseDuration(text: String) throws -> (Int64, Int32) {
4545
}
4646
let digitString = String(digits)
4747
if let s = Int64(digitString),
48-
s >= minDurationSeconds && s <= maxDurationSeconds {
48+
s >= minDurationSeconds && s <= maxDurationSeconds {
4949
seconds = s
5050
} else {
5151
throw JSONDecodingError.malformedDuration
@@ -77,7 +77,7 @@ private func parseDuration(text: String) throws -> (Int64, Int32) {
7777
// No fraction, we just have an integral number of seconds
7878
let digitString = String(digits)
7979
if let s = Int64(digitString),
80-
s >= minDurationSeconds && s <= maxDurationSeconds {
80+
s >= minDurationSeconds && s <= maxDurationSeconds {
8181
seconds = s
8282
} else {
8383
throw JSONDecodingError.malformedDuration
@@ -137,7 +137,7 @@ extension Google_Protobuf_Duration: _CustomJSONCodable {
137137

138138
extension Google_Protobuf_Duration: ExpressibleByFloatLiteral {
139139
public typealias FloatLiteralType = Double
140-
140+
141141
/// Creates a new `Google_Protobuf_Duration` from a floating point literal
142142
/// that is interpreted as a duration in seconds, rounded to the nearest
143143
/// nanosecond.
@@ -160,11 +160,10 @@ extension Google_Protobuf_Duration {
160160
let (s, n) = normalizeForDuration(seconds: Int64(sd), nanos: Int32(nd))
161161
self.init(seconds: s, nanos: n)
162162
}
163-
163+
164164
/// The `TimeInterval` (measured in seconds) equal to this duration.
165165
public var timeInterval: TimeInterval {
166-
return TimeInterval(self.seconds) +
167-
TimeInterval(self.nanos) / TimeInterval(nanosPerSecond)
166+
return TimeInterval(self.seconds) + TimeInterval(self.nanos) / TimeInterval(nanosPerSecond)
168167
}
169168
}
170169

@@ -174,14 +173,14 @@ private func normalizeForDuration(
174173
) -> (seconds: Int64, nanos: Int32) {
175174
var s = seconds
176175
var n = nanos
177-
176+
178177
// If the magnitude of n exceeds a second then
179178
// we need to factor it into s instead.
180179
if n >= nanosPerSecond || n <= -nanosPerSecond {
181180
s += Int64(n / nanosPerSecond)
182181
n = n % nanosPerSecond
183182
}
184-
183+
185184
// The Duration spec says that when s != 0, s and
186185
// n must have the same sign.
187186
if s > 0 && n < 0 {
@@ -191,7 +190,7 @@ private func normalizeForDuration(
191190
n -= nanosPerSecond
192191
s += 1
193192
}
194-
193+
195194
return (seconds: s, nanos: n)
196195
}
197196

Sources/SwiftProtobuf/JSONScanner.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private func parseBytes(
122122
) throws -> Data {
123123
let c = source[index]
124124
if c != asciiDoubleQuote {
125-
throw JSONDecodingError.malformedString
125+
throw JSONDecodingError.malformedString
126126
}
127127
source.formIndex(after: &index)
128128

@@ -142,20 +142,20 @@ private func parseBytes(
142142
if digit == asciiBackslash {
143143
source.formIndex(after: &index)
144144
if index == end {
145-
throw JSONDecodingError.malformedString
145+
throw JSONDecodingError.malformedString
146146
}
147147
let escaped = source[index]
148148
switch escaped {
149149
case asciiLowerU:
150150
// TODO: Parse hex escapes such as \u0041. Note that
151151
// such escapes are going to be extremely rare, so
152152
// there's little point in optimizing for them.
153-
throw JSONDecodingError.malformedString
153+
throw JSONDecodingError.malformedString
154154
case asciiForwardSlash:
155155
digit = escaped
156156
default:
157157
// Reject \b \f \n \r \t \" or \\ and all illegal escapes
158-
throw JSONDecodingError.malformedString
158+
throw JSONDecodingError.malformedString
159159
}
160160
}
161161

@@ -173,11 +173,11 @@ private func parseBytes(
173173

174174
// We reached the end without seeing the close quote
175175
if index == end {
176-
throw JSONDecodingError.malformedString
176+
throw JSONDecodingError.malformedString
177177
}
178178
// Reject mixed encodings.
179179
if sawSection4Characters && sawSection5Characters {
180-
throw JSONDecodingError.malformedString
180+
throw JSONDecodingError.malformedString
181181
}
182182

183183
// Allocate a Data object of exactly the right size
@@ -671,7 +671,7 @@ internal struct JSONScanner {
671671
return nil
672672
}
673673
if c >= asciiZero && c <= asciiNine {
674-
throw JSONDecodingError.leadingZero
674+
throw JSONDecodingError.leadingZero
675675
}
676676
case asciiOne...asciiNine:
677677
while c >= asciiZero && c <= asciiNine {
@@ -1209,7 +1209,7 @@ internal struct JSONScanner {
12091209
default: break
12101210
}
12111211
}
1212-
throw JSONDecodingError.malformedBool
1212+
throw JSONDecodingError.malformedBool
12131213
}
12141214

12151215
/// Returns pointer/count spanning the UTF8 bytes of the next regular
@@ -1309,7 +1309,7 @@ internal struct JSONScanner {
13091309
}
13101310
skipWhitespace()
13111311
guard hasMoreContent else {
1312-
throw JSONDecodingError.truncated
1312+
throw JSONDecodingError.truncated
13131313
}
13141314
if currentByte == asciiDoubleQuote {
13151315
if let name = try nextOptionalKey() {
@@ -1446,7 +1446,7 @@ internal struct JSONScanner {
14461446
try skipObject()
14471447
case asciiCloseSquareBracket: // ] ends an empty array
14481448
if arrayDepth == 0 {
1449-
throw JSONDecodingError.failure
1449+
throw JSONDecodingError.failure
14501450
}
14511451
// We also close out [[]] or [[[]]] here
14521452
while arrayDepth > 0 && skipOptionalArrayEnd() {
@@ -1456,19 +1456,19 @@ internal struct JSONScanner {
14561456
if !skipOptionalKeyword(bytes: [
14571457
asciiLowerN, asciiLowerU, asciiLowerL, asciiLowerL
14581458
]) {
1459-
throw JSONDecodingError.truncated
1459+
throw JSONDecodingError.truncated
14601460
}
14611461
case asciiLowerF: // f must be false
14621462
if !skipOptionalKeyword(bytes: [
14631463
asciiLowerF, asciiLowerA, asciiLowerL, asciiLowerS, asciiLowerE
14641464
]) {
1465-
throw JSONDecodingError.truncated
1465+
throw JSONDecodingError.truncated
14661466
}
14671467
case asciiLowerT: // t must be true
14681468
if !skipOptionalKeyword(bytes: [
14691469
asciiLowerT, asciiLowerR, asciiLowerU, asciiLowerE
14701470
]) {
1471-
throw JSONDecodingError.truncated
1471+
throw JSONDecodingError.truncated
14721472
}
14731473
default: // everything else is a number token
14741474
_ = try nextDouble()

Sources/SwiftProtobuf/Message+JSONAdditions.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extension Message {
3434
let data: [UInt8] = try jsonUTF8Bytes(options: options)
3535
return String(bytes: data, encoding: .utf8)!
3636
}
37-
37+
3838
/// Returns a `SwiftProtobufContiguousBytes` containing the UTF-8 JSON serialization of the message.
3939
///
4040
/// Unlike binary encoding, presence of required fields is not enforced when
@@ -57,7 +57,7 @@ extension Message {
5757
visitor.endObject()
5858
return Bytes(visitor.dataResult)
5959
}
60-
60+
6161
/// Creates a new message by decoding the given string containing a
6262
/// serialized message in JSON format.
6363
///
@@ -70,7 +70,7 @@ extension Message {
7070
) throws {
7171
try self.init(jsonString: jsonString, extensions: nil, options: options)
7272
}
73-
73+
7474
/// Creates a new message by decoding the given string containing a
7575
/// serialized message in JSON format.
7676
///
@@ -92,7 +92,7 @@ extension Message {
9292
throw JSONDecodingError.truncated
9393
}
9494
}
95-
95+
9696
/// Creates a new message by decoding the given `SwiftProtobufContiguousBytes`
9797
/// containing a serialized message in JSON format, interpreting the data as UTF-8 encoded
9898
/// text.
@@ -107,7 +107,7 @@ extension Message {
107107
) throws {
108108
try self.init(jsonUTF8Bytes: jsonUTF8Bytes, extensions: nil, options: options)
109109
}
110-
110+
111111
/// Creates a new message by decoding the given `SwiftProtobufContiguousBytes`
112112
/// containing a serialized message in JSON format, interpreting the data as UTF-8 encoded
113113
/// text.

0 commit comments

Comments
 (0)