Encontrar com eficiência todas as correspondências sobrepostas para uma expressão regular

Este é um acompanhamento paraTodos os substrings sobrepostos que correspondem a um java regex.

Existe uma maneira de tornar esse código mais rápido?

public static void allMatches(String text, String regex)
  {
    for (int i = 0; i < text.length(); ++i) {
      for (int j = i + 1; j <= text.length(); ++j) {
        String positionSpecificPattern = "((?<=^.{"+i+"})("+regex+")(?=.{"+(text.length() - j)+"}$))";
        Matcher m = Pattern.compile(positionSpecificPattern).matcher(text);

        if (m.find()) 
        {   
          System.out.println("Match found: \"" + (m.group()) + "\" at position [" + i + ", " + j + ")");
        }   
      }   
    }   
  }

questionAnswers(1)

yourAnswerToTheQuestion