Skip to content

Commit

Permalink
Improved Collection Safe Subscript Performance
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrommcarrasco committed Apr 3, 2019
1 parent 38e490a commit 8b06257
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sucrose.podspec
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.swift_version = "5.0"
s.name = "Sucrose"
s.version = "3.3.0"
s.version = "3.3.1"
s.summary = "🍬 Everyday sugar"
s.description = "Collection of handy methods & objects"

Expand Down
2 changes: 1 addition & 1 deletion Sucrose/Extensions/Collection+SafeIndex.swift
Expand Up @@ -11,6 +11,6 @@ import Foundation
public extension Collection {

subscript(safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
return index < endIndex && index >= startIndex ? self[index] : nil
}
}

0 comments on commit 8b06257

Please sign in to comment.