Repository navigation
Split the Rust wildmatch port into smaller functions - #2703
somewhatabstract wants to merge 3 commits into
Conversation
dowild was one long function with nested loops for `*`. It's now split into named steps, each with its own tests, and behaves exactly as before: - match_wild_from walks the pattern and text, as dowild did. - match_star handles a run of `*` and what follows it. - read_star_run works out whether a run of `*` can cross `/`. - try_star_start_points tries each place a `*` could stop. - skip_to_literal skips ahead to the literal byte after a `*`. - byte_at, fold_byte and find_slash are the small byte helpers they share. The match outcome, the pattern and text with their options, and the two `*` results are types in types.rs. The results still match git's C wildmatch on 300,000 random cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QjLhVH1NnUc7MzCSYLd8Yn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QjLhVH1NnUc7MzCSYLd8Yn
🦋 Changeset detectedLatest commit: 430a9ef The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2703 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 93 101 +8
Lines 3177 3513 +336
Branches 2383 2721 +338
==========================================
+ Hits 3177 3513 +336
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Bundle ReportBundle size has no change ✅ |
- Keep each doc summary to one line. - find_slash returns None past the end of the text rather than panicking. - skip_to_literal's doc says it never finds a `/` for a `*` that can't match one, which callers handle first. - read_star_run works out match_slash in one place. - try_star_start_points reads the byte after the `*` once, before its loop. The results still match git's C wildmatch on 300,000 random cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QjLhVH1NnUc7MzCSYLd8Yn
|
I'm closing this unmerged. The Rust Generated by Claude Code |
The Rust port of git's
wildmatchwas one longdowildfunction with nested loops for*, which was hard to follow. This splits it into named steps, each in its own file with its own tests. Behaviour doesn't change.match_wild_fromwalks the pattern and text together, asdowilddid.match_starhandles a run of*and what follows it.read_star_runworks out whether a run of*can cross/.try_star_start_pointstries each place a*could stop.skip_to_literalskips ahead to the literal byte after a*.byte_at,fold_byteandfind_slashare the small byte helpers they share.The new shared types are in
types.rs. This is the first of five PRs forget_filesin Rust (#2615). The next ones add brace expansion and a dotfile option to this matcher.Test plan
wildmatchon the same 300,000 random cases as before, and the results are identical.match_wild_fromandmatch_starside by side with git'sdowildand check that they follow it.Generated by Claude Code