public int diff_commonPrefix(String text1, String text2) {
    // Performance analysis: http://neil.fraser.name/news/2007/10/09/
    int n = Math.min(text1.length(), text2.length());
    for (int i = 0; i < n; i++) {
      if (text1.charAt(i) != text2.charAt(i)) {
        return i;
      }
    }
    return n;
  }
Determine the common prefix of two strings

@param text1 First string.
@param text2 Second string.
@return The number of characters common to the start of each string.
src/burp/Utils/diff_match_patch.java