MCPcopy Create free account
hub / github.com/davidblewett/rure-python / should_exec

Function should_exec

regex/src/backtrack.rs:41–50  ·  view source on GitHub ↗

Returns true iff the given regex and input should be executed by this engine with reasonable memory usage.

(num_insts: usize, text_len: usize)

Source from the content-addressed store, hash-verified

39/// Returns true iff the given regex and input should be executed by this
40/// engine with reasonable memory usage.
41pub fn should_exec(num_insts: usize, text_len: usize) -> bool {
42 // Total memory usage in bytes is determined by:
43 //
44 // ((len(insts) * (len(input) + 1) + bits - 1) / bits) * (size_of(u32))
45 //
46 // The actual limit picked is pretty much a heuristic.
47 // See: https://github.com/rust-lang/regex/issues/215
48 let size = ((num_insts * (text_len + 1) + BIT_SIZE - 1) / BIT_SIZE) * 4;
49 size <= MAX_SIZE_BYTES
50}
51
52/// A backtracking matching engine.
53#[derive(Debug)]

Callers 1

exec_nfaMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected