Skip to content

Commit

Permalink
Simplify logic when decrementing to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
djones6 authored and youming-lin committed Sep 13, 2017
1 parent 969ad23 commit ab37545
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Sources/KituraNet/HTTP/KeepAliveState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ public enum KeepAliveState {
switch self {
case .unlimited: break
case .limited(let limit):
if limit > 1 {
self = .limited(maxRequests: limit - 1)
} else {
assert(limit > 0, "Cannot decrement with zero requests remaining")
self = .disabled
}
assert(limit > 0, "Cannot decrement with zero requests remaining")
self = .limited(maxRequests: limit - 1)
case .disabled:
assertionFailure("Cannot decrement when Keep-Alive is disabled")
}
Expand Down

0 comments on commit ab37545

Please sign in to comment.