Skip to content

Commit 2d6c792

Browse files
committed
simplify linear buckets creation
1 parent 3741af3 commit 2d6c792

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

Sources/Prometheus/MetricTypes/Histogram.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,7 @@ public struct Buckets: ExpressibleByArrayLiteral {
3939
/// - count: Amount of buckets to generate, should be larger than zero. The +Inf bucket is not included in this count.
4040
public static func linear(start: Double, width: Double, count: Int) -> Buckets {
4141
assert(count >= 1, "Bucket.linear needs a count larger than 1")
42-
var arr = [Double]()
43-
var s = start
44-
for _ in 0..<count {
45-
arr.append(s)
46-
s += width
47-
}
42+
let arr = (0..<count).map { Double(start) + Double($0) * Double(width) }
4843
return Buckets(arr)
4944
}
5045

0 commit comments

Comments
 (0)