Skip to content

Commit 17e0f96

Browse files
committed
Simplify limit() logic
At least for the functional mindset. A short one-liner should be more readable than an if-else. Signed-off-by: Stephen Celis <stephen@stephencelis.com>
1 parent 6d9fb5c commit 17e0f96

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

SQLite/Query.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,7 @@ public struct Query {
273273
// prevents limit(nil, offset: 5)
274274
private func limit(#to: Int?, offset: Int? = nil) -> Query {
275275
var query = self
276-
if let to = to {
277-
query.limit = (to, offset)
278-
} else {
279-
query.limit = nil
280-
}
276+
query.limit = to.map { ($0, offset) }
281277
return query
282278
}
283279

0 commit comments

Comments
 (0)