Skip to content

Commit

Permalink
A fix for #3848. Use a stock iterator instead of a custom one. (#3891)
Browse files Browse the repository at this point in the history
  • Loading branch information
phughes authored and jjatie committed Mar 9, 2019
1 parent b4e300a commit a969c46
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,18 @@ extension BarLineScatterCandleBubbleRenderer.XBounds: RangeExpression {

extension BarLineScatterCandleBubbleRenderer.XBounds: Sequence {
public struct Iterator: IteratorProtocol {
private let bounds: BarLineScatterCandleBubbleRenderer.XBounds
private var value: Int

fileprivate init(bounds: BarLineScatterCandleBubbleRenderer.XBounds) {
self.bounds = bounds
self.value = bounds.min
private var iterator: IndexingIterator<ClosedRange<Int>>

fileprivate init(min: Int, max: Int) {
self.iterator = (min...max).makeIterator()
}

public mutating func next() -> Int? {
guard value < bounds.max else { return nil }
value += 1
return value
return self.iterator.next()
}
}

public func makeIterator() -> Iterator {
return Iterator(bounds: self)
return Iterator(min: self.min, max: self.max)
}
}

0 comments on commit a969c46

Please sign in to comment.