Skip to content

Commit

Permalink
Merge pull request #2580 from Adlai-Holler/BufferOptimization
Browse files Browse the repository at this point in the history
Make BufferState.addValue Slightly Quicker
  • Loading branch information
NachoSoto committed Nov 30, 2015
2 parents 891b0e0 + 91dfa40 commit dbb5d53
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ReactiveCocoa/Swift/SignalProducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ private struct BufferState<Value, Error: ErrorType> {
mutating func addValue(value: Value, upToCapacity capacity: Int) {
values.append(value)

while values.count > capacity {
values.removeAtIndex(0)
let overflow = values.count - capacity
if overflow > 0 {
values.removeRange(0..<overflow)
}
}
}
Expand Down

0 comments on commit dbb5d53

Please sign in to comment.