⚡️ Faster fc.webPath/fc.webUrl on generate#7048
Merged
Merged
Conversation
`segmentsToPathMapper` built the path with
`join(map(segments, (v) => `/${v}`), '')`, which allocates an
intermediate array of `/segment` strings and invokes a per-element
arrow closure before joining. Fuse it into a single accumulating loop
that appends `'/' + segment` directly, removing the intermediate array
and the map callback. Pure string-assembly refactor; the unmapper and
generated values are unchanged.
https://claude.ai/code/session_01SRx4yxfDXbBWd5JDy7nrtz
🦋 Changeset detectedLatest commit: 31878c9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
@fast-check/ava
fast-check
@fast-check/jest
@fast-check/packaged
@fast-check/poisoning
@fast-check/vitest
@fast-check/worker
commit: |
Contributor
⏱️ Benchmark ResultsClick to expand |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7048 +/- ##
==========================================
+ Coverage 94.86% 94.87% +0.01%
==========================================
Files 212 212
Lines 5884 5896 +12
Branches 1543 1548 +5
==========================================
+ Hits 5582 5594 +12
Misses 294 294
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dubzzz
enabled auto-merge (squash)
June 5, 2026 03:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is a performance-only change to the path-assembly mapper shared by
fc.webPathandfc.webUrl. Generated values are unchanged — only the speed ofgenerateimproves. No public API change, no behavior change for end users.Measured improvement (interleaved separate-process A/B, median of medians):
webPath(): ~−10% ns/op (≈1376 → ≈1236 ns/op) — the direct beneficiary, andwebPathis itself public API.webUrl(): ~−4% ns/op (≈9515 → ≈9123 ns/op) — a smaller relative gain because most ofwebUrl's cost is in authority/domain generation; the path-assembly saving is real but a smaller share of the whole.Why
segmentsToPathMapperassembled the path as:That allocates an intermediate array of
/segmentstrings and invokes a per-element arrow closure for every segment, then joins. Fusing it into a single accumulating loop removes both the intermediate array and themapcallback:Scope, correctness and impact
fast-check: patch,⚡️ Faster fc.webPath/fc.webUrl on generate) is included._internals/mappers/SegmentsToPath.ts) plus the changeset. Only the forward mapper changed; the unmapper is untouched.segmentsToPathMapperis used solely bybuildUriPathArbitrary→webPath→webUrl. It does not touch domain/authority/email code paths.webUrl,webPath,PartsToUrl,UriPath/SegmentsToPath, andemailAddressspecs all pass (25 tests). It is a pure string-assembly refactor producing byte-identical output, so no new test is needed.Checklist
— Don't delete this checklist and make sure you do the following before opening the PR
pnpm run bumpor by following the instructions from the changeset bot🐛(vitest) Something...) when the change targets a package other thanfast-checkGenerated by Claude Code