Repository navigation
Commit 8e11ec5
refactor(router): lower the shared-parts count once per braced part (#201)
<!-- claude-projects-attribution: {"github_login":"dinwwwh"} -->
_Requested by **dinwwwh** · [project
thread](https://claude.ai/code/project/chan_01UcKMz91tMarPV1kWLVgLYE?thread=cmsg_01UcKMz91tMarPV1kWLVgLYE6swgSUM9SyULmBVdRjY2t7)_
## What
`expand` tracks how many of the previous route's parts the next route
can reuse (`literals`). It used to lower that count in two places: once
where a route waits, and once where it adds a param. Both happen only
for a part that starts with `{` once decoded, so the count is now
lowered in one place, right after that check.
That check also catches a part such as `{a.b}`, which starts with `{`
but is literal text. The count now drops for that part too, so the next
route shares fewer parts with this one and parses them again. Matching
is unaffected. The comment on `shared` and `literals` now describes the
rule this way.
## Measurements
Instruction counts from callgrind, `node --single-threaded`, averaged
over hash seeds 1 and 2:
| | before | after |
|---|---|---|
| min / min+gzip | 5012 / 2092 B | 5001 / 2091 B |
| REST cold+3 match | 3.498M | 3.485M (−0.35%) |
| REST cold+3, one request per method | 5.075M | 5.064M (−0.2%) |
| REST cold+10 | 6.010M | 5.998M (−0.2%) |
`expand` only runs while the tree is being built, so steady-state
matching does not change.
## Checks
- Tests pass with 100% coverage.
- The model fuzzers, including the late-add ones, find 0 diffs.
- Stryker finds 66 survivors, down from 67, and none of them are new.
The `if (true)` mutant of the merged check is killed by the late-add
test added in #195.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01VVaw7Sutbw6xMTMyDFeNfw)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent f18cd06 commit 8e11ec5
1 file changed
Lines changed: 5 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | | - | |
375 | | - | |
| 374 | + | |
| 375 | + | |
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| |||
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
402 | 405 | | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | 421 | | |
425 | 422 | | |
426 | 423 | | |
| |||
0 commit comments