Skip to content

Commit 5541987

Browse files
committed
Fix warnings in benchmarks
1 parent dfc3933 commit 5541987

File tree

7 files changed

+36
-50
lines changed

7 files changed

+36
-50
lines changed

benchmark/single-source/DictTest.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public func run_Dictionary(scale: Int) {
146146
"IncorrectResults in DictTest: \(count) != \(N*541).")
147147
}
148148

149-
class Box<T : Hashable where T : Equatable> : Hashable {
149+
class Box<T : Hashable> : Hashable {
150150
var value: T
151151

152152
init(_ v: T) {
@@ -156,13 +156,10 @@ class Box<T : Hashable where T : Equatable> : Hashable {
156156
var hashValue: Int {
157157
return value.hashValue
158158
}
159-
}
160-
161-
extension Box : Equatable {
162-
}
163159

164-
func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
165-
return lhs.value == rhs.value
160+
static func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
161+
return lhs.value == rhs.value
162+
}
166163
}
167164

168165
@inline(never)

benchmark/single-source/DictTest2.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public func run_Dictionary2(_ N: Int) {
3737
CheckResults(res == ref_result, "Incorrect results in Dictionary2: \(res) != \(ref_result)")
3838
}
3939

40-
class Box<T : Hashable where T : Equatable> : Hashable {
40+
class Box<T : Hashable> : Hashable {
4141
var value: T
4242

4343
init(_ v: T) {
@@ -47,13 +47,10 @@ class Box<T : Hashable where T : Equatable> : Hashable {
4747
var hashValue: Int {
4848
return value.hashValue
4949
}
50-
}
51-
52-
extension Box : Equatable {
53-
}
5450

55-
func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
56-
return lhs.value == rhs.value
51+
static func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
52+
return lhs.value == rhs.value
53+
}
5754
}
5855

5956
@inline(never)

benchmark/single-source/DictTest3.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public func run_Dictionary3(_ N: Int) {
4444
CheckResults(res == ref_result, "Incorrect results in Dictionary3: \(res) != \(ref_result)")
4545
}
4646

47-
class Box<T : Hashable where T : Equatable> : Hashable {
47+
class Box<T : Hashable> : Hashable {
4848
var value: T
4949

5050
init(_ v: T) {

benchmark/single-source/DictionaryRemove.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public func run_DictionaryRemove(_ N: Int) {
4242
"tmpDict should be empty: \(tmpDict.count) != 0.")
4343
}
4444

45-
class Box<T : Hashable where T : Equatable> : Hashable {
45+
class Box<T : Hashable> : Hashable {
4646
var value: T
4747

4848
init(_ v: T) {
@@ -52,13 +52,10 @@ class Box<T : Hashable where T : Equatable> : Hashable {
5252
var hashValue: Int {
5353
return value.hashValue
5454
}
55-
}
56-
57-
extension Box : Equatable {
58-
}
5955

60-
func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
61-
return lhs.value == rhs.value
56+
static func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
57+
return lhs.value == rhs.value
58+
}
6259
}
6360

6461
@inline(never)

benchmark/single-source/DictionarySwap.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func swappedCorrectly(_ swapped: Bool, _ p25: Int, _ p75: Int) -> Bool {
4545
!swapped && (p25 == 25 && p75 == 75)
4646
}
4747

48-
class Box<T : Hashable where T : Equatable> : Hashable {
48+
class Box<T : Hashable> : Hashable {
4949
var value: T
5050

5151
init(_ v: T) {
@@ -55,13 +55,10 @@ class Box<T : Hashable where T : Equatable> : Hashable {
5555
var hashValue: Int {
5656
return value.hashValue
5757
}
58-
}
59-
60-
extension Box : Equatable {
61-
}
6258

63-
func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
64-
return lhs.value == rhs.value
59+
static func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
60+
return lhs.value == rhs.value
61+
}
6562
}
6663

6764
@inline(never)

benchmark/single-source/RGBHistogram.swift

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ func isCorrectHistogram(_ histogram: [(key: rrggbb_t, value: Int)]) -> Bool {
9292
histogram[156].0 == 0x003B8D96 && histogram[156].1 == 1
9393
}
9494

95-
func createSortedSparseRGBHistogram
96-
<S: Sequence where S.Iterator.Element == rrggbb_t>
97-
(_ samples: S) -> [(key: rrggbb_t, value: Int)] {
95+
func createSortedSparseRGBHistogram<S : Sequence>(
96+
_ samples: S
97+
) -> [(key: rrggbb_t, value: Int)]
98+
where S.Iterator.Element == rrggbb_t
99+
{
98100
var histogram = Dictionary<rrggbb_t, Int>()
99101

100102
for sample in samples {
@@ -111,7 +113,7 @@ func createSortedSparseRGBHistogram
111113
}
112114
}
113115

114-
class Box<T : Hashable where T : Equatable> : Hashable {
116+
class Box<T : Hashable> : Hashable {
115117
var value: T
116118

117119
init(_ v: T) {
@@ -121,13 +123,10 @@ class Box<T : Hashable where T : Equatable> : Hashable {
121123
var hashValue: Int {
122124
return value.hashValue
123125
}
124-
}
125-
126-
extension Box : Equatable {
127-
}
128126

129-
func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
130-
return lhs.value == rhs.value
127+
static func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
128+
return lhs.value == rhs.value
129+
}
131130
}
132131

133132
func isCorrectHistogramOfObjects(_ histogram: [(key: Box<rrggbb_t>, value: Box<Int>)]) -> Bool {
@@ -136,9 +135,11 @@ func isCorrectHistogramOfObjects(_ histogram: [(key: Box<rrggbb_t>, value: Box<I
136135
histogram[156].0.value == 0x003B8D96 && histogram[156].1.value == 1
137136
}
138137

139-
func createSortedSparseRGBHistogramOfObjects
140-
<S: Sequence where S.Iterator.Element == rrggbb_t>
141-
(_ samples: S) -> [(key: Box<rrggbb_t>, value: Box<Int>)] {
138+
func createSortedSparseRGBHistogramOfObjects<S : Sequence>(
139+
_ samples: S
140+
) -> [(key: Box<rrggbb_t>, value: Box<Int>)]
141+
where S.Iterator.Element == rrggbb_t
142+
{
142143
var histogram = Dictionary<Box<rrggbb_t>, Box<Int>>()
143144

144145
for sample in samples {

benchmark/single-source/SetTests.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,20 @@ public func run_SetIntersect(_ N: Int) {
104104
sink(&and)
105105
}
106106

107-
class Box<T : Hashable where T : Equatable> : Hashable {
107+
class Box<T : Hashable> : Hashable {
108108
var value: T
109109

110110
init(_ v: T) {
111111
value = v
112112
}
113113

114-
var hashValue : Int {
114+
var hashValue: Int {
115115
return value.hashValue
116116
}
117-
}
118-
119-
extension Box : Equatable {
120-
}
121117

122-
func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
123-
return lhs.value == rhs.value
118+
static func ==<T: Equatable>(lhs: Box<T>, rhs: Box<T>) -> Bool {
119+
return lhs.value == rhs.value
120+
}
124121
}
125122

126123
@inline(never)

0 commit comments

Comments
 (0)