File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
SabreTools.Hashing/SpamSum Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -105,27 +105,25 @@ public static int FuzzyCompare(string? first, string? second)
105105 /// <returns>False if there is no common substring of 7 or more characters, true if there is.</returns>
106106 private static bool HasCommmonSubstring ( string first , string second )
107107 {
108- var firstLength = first . Length ;
109- var secondLength = second . Length ;
110- var largestSubstring = 0 ;
108+ // If either string is less than 7 characters
109+ if ( first . Length < 7 || second . Length < 7 )
110+ return false ;
111111
112- for ( var i = 0 ; i < firstLength ; i ++ )
112+ for ( var i = 0 ; i < first . Length ; i ++ )
113113 {
114- for ( var j = 0 ; j < secondLength ; j ++ )
114+ for ( var j = 0 ; j < second . Length ; j ++ )
115115 {
116116 var currentIndex = 0 ;
117- while ( ( i + currentIndex ) < firstLength && ( j + currentIndex ) < secondLength && first [ i + currentIndex ] == second [ j + currentIndex ] )
117+ while ( ( i + currentIndex ) < first . Length && ( j + currentIndex ) < second . Length && first [ i + currentIndex ] == second [ j + currentIndex ] )
118118 {
119119 currentIndex ++ ;
120120 }
121121
122- largestSubstring = Math . Max ( largestSubstring , currentIndex ) ;
122+ if ( currentIndex >= 7 )
123+ return true ;
123124 }
124125 }
125126
126- if ( largestSubstring >= 7 )
127- return true ;
128-
129127 return false ;
130128 }
131129
You can’t perform that action at this time.
0 commit comments