Index: src/wp-includes/wp-diff.php
===================================================================
--- src/wp-includes/wp-diff.php	(revision 36871)
+++ src/wp-includes/wp-diff.php	(working copy)
@@ -430,22 +430,72 @@
 	 * @return int
 	 */
 	public function compute_string_distance( $string1, $string2 ) {
-		// Vectors containing character frequency for all chars in each string
-		$chars1 = count_chars($string1);
-		$chars2 = count_chars($string2);
+		$len1 = mb_strlen( $string1 );
+		$len2 = mb_strlen( $string2 );
 
-		// L1-norm of difference vector.
-		$difference = array_sum( array_map( array($this, 'difference'), $chars1, $chars2 ) );
+		$len = min( $len1, $len2 );
 
-		// $string1 has zero length? Odd. Give huge penalty by not dividing.
-		if ( !$string1 )
-			return $difference;
+		if ( $len > 600 ) {
+			// arbitrary limit on character length for speed purpose.
+			$string_distance = $len;
+		} else {
+			$string_distance = $this->levenshtein( $string1, $string2, $len1, $len2 );
+		}
 
-		// Return distance per character (of string1).
-		return $difference / strlen($string1);
+		return $string_distance;
 	}
 
 	/**
+	 * PHP implementation of Levenshtein edit distance algorithm.
+	 * Uses the native PHP implementation when possible for speed.
+	 * The native levenshtein is limited to 255 bytes.
+	 *
+	 * @since 4.5.0
+	 *
+	 * @param string $str1
+	 * @param string $str2
+	 * @param int $length1
+	 * @param int $length2
+	 * @return int
+	 */
+	public function levenshtein( $str1, $str2, $length1, $length2 ) {
+		if ( $length1 == 0 ) {
+			return $length2;
+		}
+		if ( $length2 == 0 ) {
+			return $length1;
+		}
+		if ( $str1 === $str2 ) {
+			return 0;
+		}
+
+		$bytelength1 = strlen( $str1 );
+		$bytelength2 = strlen( $str2 );
+		if ( $bytelength1 === $length1 && $bytelength1 <= 255
+			&& $bytelength2 === $length2 && $bytelength2 <= 255
+		) {
+			return levenshtein( $str1, $str2 );
+		}
+
+		$prevRow = range( 0, $length2 );
+		for ( $i = 0; $i < $length1; $i++ ) {
+			$currentRow = array();
+			$currentRow[0] = $i + 1;
+			$c1 = mb_substr( $str1, $i, 1 );
+			for ( $j = 0; $j < $length2; $j++ ) {
+				$c2 = mb_substr( $str2, $j, 1 );
+				$insertions = $prevRow[$j + 1] + 1;
+				$deletions = $currentRow[$j] + 1;
+				$substitutions = $prevRow[$j] + ( ( $c1 != $c2 ) ? 1 : 0 );
+				$currentRow[] = min( $insertions, $deletions, $substitutions );
+			}
+			$prevRow = $currentRow;
+		}
+
+		return $prevRow[$length2];
+	}	
+
+	/**
 	 * @ignore
 	 * @since 2.6.0
 	 *
