Skip to content

Commit 4612a5b

Browse files
committed
[benchmark] Cleanup and bug fix
1 parent 73af20f commit 4612a5b

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

benchmark/single-source/StringSplitting.swift

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ public let StringSplitting = [
4545
setUpFunction: setup),
4646
]
4747

48-
private var c = 0
49-
50-
@inline(never)
51-
public func blackHole(_ x: String) {
52-
c += x.isEmpty ? 1 : 0
53-
}
54-
55-
5648

5749
// Line-sink benchmarks: Implement `lines`-like functionality
5850
enum View {
@@ -108,9 +100,9 @@ fileprivate func _linesByScalars(
108100
source scalarSource: () throws -> Unicode.Scalar?,
109101
sink lineSink: (String) -> ()
110102
) rethrows {
111-
guard #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
112-
fatalError("unavailable")
113-
}
103+
guard #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
104+
fatalError("unavailable")
105+
}
114106

115107
var buffer: Array<UInt8> = []
116108
func yield() {
@@ -141,7 +133,7 @@ fileprivate func _linesByScalars(
141133
}
142134
}
143135

144-
// Inline always to try to ignore any closure stuff
136+
145137
@inline(__always)
146138
fileprivate func _linesByBytes(
147139
source byteSource: () throws -> UInt8?,
@@ -171,6 +163,7 @@ fileprivate func _linesByBytes(
171163
guard let next = try byteSource() else { return }
172164
if next != _LF { buffer.append(next) }
173165
case 0x0A..<0x0D: yield()
166+
174167
case 0xE2:
175168
// Try to read: 80 [A8 | A9].
176169
// If we can't, then we put the byte in the buffer for error correction
@@ -304,7 +297,7 @@ private let alphaInteriorNewlines: String =
304297
)def\(Unicode.Scalar(0x0B)! // VT
305298
)ghi\(Unicode.Scalar(0x0C)! // FF
306299
)jkl\(Unicode.Scalar(0x0D)! // CR
307-
)mno\(Unicode.Scalar(0x0D)! // CR-LF
300+
)mno\(Unicode.Scalar(0x0D)!)\(Unicode.Scalar(0x0A)! // CR-LF
308301
)pqr\(Unicode.Scalar(0x2028)! // LS
309302
)stu\(Unicode.Scalar(0x2029)! // PS
310303
)vwx

0 commit comments

Comments
 (0)