From 960bca13c0207014040b96ba22e586b688279be9 Mon Sep 17 00:00:00 2001 From: mmazzei Date: Sun, 25 Dec 2016 17:58:00 -0300 Subject: [PATCH] Removed redundant validation. --- Boyer-Moore/BoyerMoore.playground/Contents.swift | 3 --- Boyer-Moore/BoyerMoore.swift | 3 --- Boyer-Moore/README.markdown | 6 ------ 3 files changed, 12 deletions(-) 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