class
Analyzer::Scala::Scalatra
Defined in:
analyzer/analyzers/scala/scalatra.crConstant Summary
-
CLASS_OBJECT_TRAIT_RE =
Regex.union("class", "object", "trait") -
Same rationale: replaces the three
includes?calls gating theclass/object/traitdeclaration scan insingle_mount_prefix. -
HTTP_METHODS =
["get", "post", "put", "delete", "patch", "head", "options"] of ::String -
ROUTE_PATTERNS =
HTTP_METHODS.map do |method| {method, /(?<![.\w])#{method}\s*\(\s*"([^"]+)"/} end -
Crystal recompiles an interpolated regex literal on every evaluation (a full PCRE2 JIT compile), and this matcher used to be rebuilt for every verb on every line — precompile the fixed set once at load time.
-
TEST_PATH_RE =
Regex.union("/src/test/", "/src/sbt-test/") -
One precompiled
Regex.unionscan (PCRE2 JIT) replaces two separateString#includes?scans of the same path -- Crystal'sincludes?is not Boyer-Moore accelerated, so a single regex pass is cheaper than two. Equivalent to the OR-of-substrings it replaces (union escapes each literal).