Skip to content

feat: improve prefilter#39

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

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

Conversation

@shu-kitamura

Copy link
Copy Markdown
Owner

Analyze ast and see the following

  • find must literals
  • nullable
  • needless (candidate)

Copilot AI review requested due to automatic review settings February 14, 2026 06:37

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 PR enhances the regex engine's prefilter optimization by introducing AST-based analysis to extract must-have literals, candidate needles, and nullable information. The improvements enable early rejection of non-matching inputs and optimized search starting positions.

Changes:

  • Added comprehensive AST analysis infrastructure to extract must literals (guaranteed to appear in matches), needles (candidate search positions), and nullable status
  • Refactored regex matching to use a multi-stage prefilter: nullable fast-path, must-literal filtering, needle-based position hinting, and full evaluation fallback
  • Updated the evaluator to support matching from multiple candidate starting positions instead of just one

Reviewed changes

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

Show a summary per file
File Description
crates/regex-core/src/engine/ast.rs Implements AST analysis logic for extracting must literals, needles, and nullable information with comprehensive test coverage
crates/regex-core/src/lib.rs Integrates prefilter optimizations into the Regex struct with nullable/must/needle checks and byte-to-char position conversion
crates/regex-core/src/engine/evaluator.rs Extends evaluator to match from multiple starting positions (renamed eval_from_start to eval_from_starts)
crates/regex-core/src/engine.rs Adds compile_pattern_with_analysis to return both compiled instructions and analysis results
.github/instructions/review/pr-review.instructions.md Adds Copilot review instructions (unrelated to prefilter functionality)


You are a senior code reviewer ensuring high standards of code quality

When performing a code review, **respond in Japanese**.

Copilot AI Feb 14, 2026

Copy link

Choose a reason for hiding this comment

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

The instruction to "respond in Japanese" seems unusual for a codebase that uses English throughout. This should be removed unless there's a specific reason for requiring Japanese responses in code reviews.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +24
# GitHub Copilot Instructions

You are a senior code reviewer ensuring high standards of code quality

When performing a code review, **respond in Japanese**.
Please focus on the following checklist:

## Checklist

- Code is simple and readable
- Functions and variables are well-named
- No duplicated code
- Proper error handling
- No exposed secrets or API keys
- Input validation implemented
- Good test coverage
- Performance considerations addressed
- Time complexity of algorithms analyzed
- Integrated libraries have compatible licenses (no license conflicts in dependencies)
- No overly large functions (>50 lines)
- No overly large files (>800 lines)
- No deeply nested logic (>4 levels)
- No hardcoded configuration values; configuration is externalized
- No unexplained magic numbers; constants are named and documented

Copilot AI Feb 14, 2026

Copy link

Choose a reason for hiding this comment

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

This entire file appears to be unrelated to the PR's stated purpose of improving prefilter functionality. The PR description mentions analyzing AST for must literals, nullable, and needles, but doesn't mention adding Copilot review instructions. Consider removing this file from this PR or explaining its relevance in the PR description.

Copilot uses AI. Check for mistakes.
@shu-kitamura
shu-kitamura merged commit 7e9f2c8 into main Feb 14, 2026
14 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