private LinkedList<Diff> diff_main(String text1,String text2,boolean checklines,long deadline){
  if (text1 == null || text2 == null) {
    throw new IllegalArgumentException("Null inputs. (diff_main)");
  }
  LinkedList<Diff> diffs;
  if (text1.equals(text2)) {
    diffs=new LinkedList<Diff>();
    if (text1.length() != 0) {
      diffs.add(new Diff(Operation.EQUAL,text1));
    }
    return diffs;
  }
  int commonlength=diff_commonPrefix(text1,text2);
  String commonprefix=text1.substring(0,commonlength);
  text1=text1.substring(commonlength);
  text2=text2.substring(commonlength);
  commonlength=diff_commonSuffix(text1,text2);
  String commonsuffix=text1.substring(text1.length() - commonlength);
  text1=text1.substring(0,text1.length() - commonlength);
  text2=text2.substring(0,text2.length() - commonlength);
  diffs=diff_compute(text1,text2,checklines,deadline);
  if (commonprefix.length() != 0) {
    diffs.addFirst(new Diff(Operation.EQUAL,commonprefix));
  }
  if (commonsuffix.length() != 0) {
    diffs.addLast(new Diff(Operation.EQUAL,commonsuffix));
  }
  diff_cleanupMerge(diffs);
  return diffs;
}

private LinkedList < Diff > diff_main ( String text1 , String text2 , boolean checklines , long deadline ) { if ( text1 == null || text2 == null ) { throw new IllegalArgumentException ( "Null inputs. (diff_main)" ) ; } LinkedList < Diff > diffs ; if ( text1 . equals ( text2 ) ) { diffs = new LinkedList < Diff > ( ) ; if ( text1 . length ( ) != 0 ) { diffs . add ( new Diff ( Operation . EQUAL , text1 ) ) ; } return diffs ; } int commonlength = diff_commonPrefix ( text1 , text2 ) ; String commonprefix = text1 . substring ( 0 , commonlength ) ; text1 = text1 . substring ( commonlength ) ; text2 = text2 . substring ( commonlength ) ; commonlength = diff_commonSuffix ( text1 , text2 ) ; String commonsuffix = text1 . substring ( text1 . length ( ) - commonlength ) ; text1 = text1 . substring ( 0 , text1 . length ( ) - commonlength ) ; text2 = text2 . substring ( 0 , text2 . length ( ) - commonlength ) ; diffs = diff_compute ( text1 , text2 , checklines , deadline ) ; if ( commonprefix . length ( ) != 0 ) { diffs . addFirst ( new Diff ( Operation . EQUAL , commonprefix ) ) ; } if ( commonsuffix . length ( ) != 0 ) { diffs . addLast ( new Diff ( Operation . EQUAL , commonsuffix ) ) ; } diff_cleanupMerge ( diffs ) ; return diffs ; }
find the differences between two texts . simplifies the problem by stripping any common prefix or suffix off the texts before diffing .
