Skip to content

feat: improve prefilter#38

Merged
shu-kitamura merged 8 commits into
mainfrom
develop
Feb 13, 2026
Merged

feat: improve prefilter#38
shu-kitamura merged 8 commits into
mainfrom
develop

Conversation

@shu-kitamura

Copy link
Copy Markdown
Owner

This pull request introduces a comprehensive regex pattern analysis to the regex-core crate, enabling extraction of deterministic "must-have" substrings, candidate literals (needles), and nullability from regex ASTs. The engine and evaluator APIs are updated to leverage these analyses, improving pre-filtering and match logic. Extensive tests are added to verify correctness and edge cases.

Regex pattern analysis and integration:

  • Added the AstAnalysis struct and the analyze_ast function to engine/ast.rs, which extract must-have substrings, candidate literals, and nullability from regex ASTs. Limits are enforced to prefer longer literals and lexicographic order.
  • Updated the Regex struct in lib.rs to store must_literals, needles, and nullable, and to initialize these via compile_pattern_with_analysis, replacing the previous first_strings logic. [1] [2]
  • Added new engine functions: compile_pattern_with_analysis and compile_pattern_with_must_literals, which return compiled instructions along with analysis results.

Evaluator and matching improvements:

  • Changed eval_from_start to eval_from_starts in evaluator.rs, allowing matching from multiple provided start indices, and updated engine and tests accordingly. [1] [2]
  • Updated tests in engine.rs and evaluator.rs to verify new analysis features, must literals extraction, needle extraction, nullability, and multi-start matching. [1] [2] [3]

Documentation and review instructions:

  • Added a Japanese-language code review checklist for Copilot reviewers in .github/instructions/review/pr-review.instructions.md, emphasizing code quality, naming, error handling, test coverage, and performance.

Copilot AI review requested due to automatic review settings February 13, 2026 15:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces comprehensive regex pattern analysis to improve prefiltering performance in the regex-core crate. The changes extract deterministic "must-have" literals, candidate literals (needles), and nullability from regex ASTs, enabling more efficient matching through multi-level prefiltering before full VM evaluation.

Changes:

  • Added AST analysis infrastructure (AstAnalysis struct and analyze_ast function) to extract must_literals, needles, and nullability from regex patterns
  • Updated the Regex API to leverage analysis results with a multi-level prefiltering strategy (nullable check → must_literals check → needle-based position hints → full VM scan)
  • Modified evaluator to support matching from multiple candidate start positions via eval_from_starts

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/regex-core/src/engine/ast.rs Implements AST analysis with functions to extract must_literals, needles, and nullable flags; includes comprehensive tests
crates/regex-core/src/lib.rs Integrates analysis results into Regex struct; implements multi-level prefiltering strategy in is_match_line
crates/regex-core/src/engine.rs Adds compile_pattern_with_analysis and compile_pattern_with_must_literals functions; updates match_line_from_start to match_line_from_starts
crates/regex-core/src/engine/evaluator.rs Changes eval_from_start to eval_from_starts to support multiple start positions
.github/instructions/review/pr-review.instructions.md Adds code review checklist guidelines for Copilot reviewers (requests Japanese responses)

@shu-kitamura
shu-kitamura merged commit 13f42bc into main Feb 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants