question: private LinkedList < Diff > diff_lineMode ( String text1 , String text2 , long deadline ) { LinesToCharsResult b = diff_linesToChars ( text1 , text2 ) ; text1 = b . chars1 ; text2 = b . chars2 ; List < String > linearray = b . lineArray ; LinkedList < Diff > diffs = diff_main ( text1 , text2 , false , deadline ) ; diff_charsToLines ( diffs , linearray ) ; diff_cleanupSemantic ( diffs ) ; diffs . add ( new Diff ( Operation . EQUAL , "" ) ) ; int count_delete = 0 ; int count_insert = 0 ; String text_delete = "" ; String text_insert = "" ; ListIterator < Diff > pointer = diffs . listIterator ( ) ; Diff thisDiff = pointer . next ( ) ; while ( thisDiff != null ) { switch ( thisDiff . operation ) { case INSERT : count_insert ++ ; text_insert += thisDiff . text ; break ; case DELETE : count_delete ++ ; text_delete += thisDiff . text ; break ; case EQUAL : if ( count_delete >= 1 && count_insert >= 1 ) { pointer . previous ( ) ; for ( int j = 0 ; j < count_delete + count_insert ; j ++ ) { pointer . previous ( ) ; pointer . remove ( ) ; } for ( Diff newDiff : diff_main ( text_delete , text_insert , false , deadline ) ) { pointer . add ( newDiff ) ; } } count_insert = 0 ; count_delete = 0 ; text_delete = "" ; text_insert = "" ; break ; } thisDiff = pointer . hasNext ( ) ? pointer . next ( ) : null ; } diffs . removeLast ( ) ; return diffs ; }
target:  Do a quick line-level diff on both strings, then rediff the parts for greater accuracy. This speedup can produce non-minimal diffs.