code: private static int suffixLength(byte[] needle, int p) {
          int len = 0;
          for (int i = p, j = needle.length - 1; i >= 0 && needle[i] == needle[j]; --i, --j) {
              len++;
          }
          return len;
      }
docs: Returns the maximum length of the substring ends at p and is a suffix.