Commits

Geoffrey French  committed 839a1b4

Fixed overflow bug in NodeElementChangeListenerDiff; if the amount of work is greater than a certain threshold, then Levenshtein differencing is not used. Unfortunately, an int overflow bug prevented this check for working in certain circumstances.

  • Participants
  • Parent commits cd24065
  • Tags 0.1.31q-alpha

Comments (0)

Files changed (1)

File java/BritefuryJ/IncrementalView/NodeElementChangeListenerDiff.java

 
 public class NodeElementChangeListenerDiff implements IncrementalView.NodeElementChangeListener
 {
-	private static final int DIFF_THRESHHOLD = 65536;
+	private static final long DIFF_THRESHHOLD = 65536L;
 
 	private static final String CARET_BOUNDARY = "\ue137";
 
 							state.reposition( newPosition, newBias );
 						}
 					}
-					else if ( ( origChangeRegionLength * newChangeRegionLength)  >  DIFF_THRESHHOLD )
+					else if ( ( (long)origChangeRegionLength * (long)newChangeRegionLength)  >  DIFF_THRESHHOLD )		// Important that we cast to longs to avoid overflows, that can EASILY happen otherwise
 					{
 						// If the m*n > DIFF_THRESHOLD, use a simpler method; this prevents slow downs