File tree Expand file tree Collapse file tree 3 files changed +0
-12
lines changed Expand file tree Collapse file tree 3 files changed +0
-12
lines changed Original file line number Diff line number Diff line change 9
9
*/
10
10
extension String {
11
11
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
-
15
12
// Cache the length of the search pattern because we're going to
16
13
// use it a few times and it's expensive to calculate.
17
14
let patternLength = pattern. characters. count
Original file line number Diff line number Diff line change 7
7
*/
8
8
extension String {
9
9
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
-
13
10
// Cache the length of the search pattern because we're going to
14
11
// use it a few times and it's expensive to calculate.
15
12
let patternLength = pattern. characters. count
Original file line number Diff line number Diff line change @@ -33,9 +33,6 @@ Here's how you could write it in Swift:
33
33
``` swift
34
34
extension String {
35
35
func index (of pattern : String ) -> Index ? {
36
- // There are no possible match in an empty string
37
- guard ! isEmpty else { return nil }
38
-
39
36
// Cache the length of the search pattern because we're going to
40
37
// use it a few times and it's expensive to calculate.
41
38
let patternLength = pattern.characters .count
@@ -160,9 +157,6 @@ Here's an implementation of the Boyer-Moore-Horspool algorithm:
160
157
``` swift
161
158
extension String {
162
159
func index (of pattern : String ) -> Index ? {
163
- // There are no possible match in an empty string
164
- guard ! isEmpty else { return nil }
165
-
166
160
// Cache the length of the search pattern because we're going to
167
161
// use it a few times and it's expensive to calculate.
168
162
let patternLength = pattern.characters .count
You can’t perform that action at this time.
0 commit comments