Skip to content

Commit

Permalink
remove max recursion from Operations.java to AutomatonTestUtil.java (#…
Browse files Browse the repository at this point in the history
…12298)

Co-authored-by: tangdonghai <tangdonghai@meituan.com>
  • Loading branch information
tang-hi and tangdonghai committed May 16, 2023
1 parent 8af3058 commit f53eb28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Expand Up @@ -61,9 +61,6 @@ public final class Operations {
*/
public static final int DEFAULT_DETERMINIZE_WORK_LIMIT = 10000;

/** Maximum level of recursion allowed in recursive operations. */
public static final int MAX_RECURSION_LEVEL = 1000;

private Operations() {}

/**
Expand Down
Expand Up @@ -46,6 +46,9 @@ public class AutomatonTestUtil {
/** Default maximum number of states that {@link Operations#determinize} should create. */
public static final int DEFAULT_MAX_DETERMINIZED_STATES = 1000000;

/** Maximum level of recursion allowed in recursive operations. */
public static final int MAX_RECURSION_LEVEL = 1000;

/** Returns random string, including full unicode range. */
public static String randomRegexp(Random r) {
while (true) {
Expand Down Expand Up @@ -483,7 +486,7 @@ public static boolean isFinite(Automaton a) {
// large automata could exceed java's stack so the maximum level of recursion is bounded to 1000
private static boolean isFinite(
Transition scratch, Automaton a, int state, BitSet path, BitSet visited, int level) {
if (level > Operations.MAX_RECURSION_LEVEL) {
if (level > MAX_RECURSION_LEVEL) {
throw new IllegalArgumentException("input automaton is too large: " + level);
}
path.set(state);
Expand Down

0 comments on commit f53eb28

Please sign in to comment.