Skip to content

Commit 960bca1

Browse files
committed
Removed redundant validation.
1 parent cf45ebd commit 960bca1

File tree

3 files changed

+0
-12
lines changed

3 files changed

+0
-12
lines changed

Boyer-Moore/BoyerMoore.playground/Contents.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
*/
1010
extension String {
1111
func index(of pattern: String, usingHorspoolImprovement: Bool = false) -> Index? {
12-
// There are no possible match in an empty string
13-
guard !isEmpty else { return nil }
14-
1512
// Cache the length of the search pattern because we're going to
1613
// use it a few times and it's expensive to calculate.
1714
let patternLength = pattern.characters.count

Boyer-Moore/BoyerMoore.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
*/
88
extension String {
99
func index(of pattern: String, usingHorspoolImprovement: Bool = false) -> Index? {
10-
// There are no possible match in an empty string
11-
guard !isEmpty else { return nil }
12-
1310
// Cache the length of the search pattern because we're going to
1411
// use it a few times and it's expensive to calculate.
1512
let patternLength = pattern.characters.count

Boyer-Moore/README.markdown

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ Here's how you could write it in Swift:
3333
```swift
3434
extension String {
3535
func index(of pattern: String) -> Index? {
36-
// There are no possible match in an empty string
37-
guard !isEmpty else { return nil }
38-
3936
// Cache the length of the search pattern because we're going to
4037
// use it a few times and it's expensive to calculate.
4138
let patternLength = pattern.characters.count
@@ -160,9 +157,6 @@ Here's an implementation of the Boyer-Moore-Horspool algorithm:
160157
```swift
161158
extension String {
162159
func index(of pattern: String) -> Index? {
163-
// There are no possible match in an empty string
164-
guard !isEmpty else { return nil }
165-
166160
// Cache the length of the search pattern because we're going to
167161
// use it a few times and it's expensive to calculate.
168162
let patternLength = pattern.characters.count

0 commit comments

Comments
 (0)