diff --git a/Boyer-Moore/BoyerMoore.playground/Contents.swift b/Boyer-Moore/BoyerMoore.playground/Contents.swift index f1ae5018e..f553e1a00 100644 --- a/Boyer-Moore/BoyerMoore.playground/Contents.swift +++ b/Boyer-Moore/BoyerMoore.playground/Contents.swift @@ -9,9 +9,6 @@ */ extension String { func index(of pattern: String, usingHorspoolImprovement: Bool = false) -> Index? { - // There are no possible match in an empty string - guard !isEmpty else { return nil } - // Cache the length of the search pattern because we're going to // use it a few times and it's expensive to calculate. let patternLength = pattern.characters.count diff --git a/Boyer-Moore/BoyerMoore.swift b/Boyer-Moore/BoyerMoore.swift index 2f6bf1392..af8aea9d9 100644 --- a/Boyer-Moore/BoyerMoore.swift +++ b/Boyer-Moore/BoyerMoore.swift @@ -7,9 +7,6 @@ */ extension String { func index(of pattern: String, usingHorspoolImprovement: Bool = false) -> Index? { - // There are no possible match in an empty string - guard !isEmpty else { return nil } - // Cache the length of the search pattern because we're going to // use it a few times and it's expensive to calculate. let patternLength = pattern.characters.count diff --git a/Boyer-Moore/README.markdown b/Boyer-Moore/README.markdown index 2cb42b0bd..e821b812e 100644 --- a/Boyer-Moore/README.markdown +++ b/Boyer-Moore/README.markdown @@ -33,9 +33,6 @@ Here's how you could write it in Swift: ```swift extension String { func index(of pattern: String) -> Index? { - // There are no possible match in an empty string - guard !isEmpty else { return nil } - // Cache the length of the search pattern because we're going to // use it a few times and it's expensive to calculate. let patternLength = pattern.characters.count @@ -160,9 +157,6 @@ Here's an implementation of the Boyer-Moore-Horspool algorithm: ```swift extension String { func index(of pattern: String) -> Index? { - // There are no possible match in an empty string - guard !isEmpty else { return nil } - // Cache the length of the search pattern because we're going to // use it a few times and it's expensive to calculate. let patternLength = pattern.characters.count