Skip to content

perf(router-core): inline getOpenAndCloseBraces in parseSegment - #8071

Merged
Sheraff merged 1 commit into
mainfrom
perf-router-core-parse-segment-inline-braces-extraction
Aug 14, 2026
Merged

perf(router-core): inline getOpenAndCloseBraces in parseSegment#8071
Sheraff merged 1 commit into
mainfrom
perf-router-core-parse-segment-inline-braces-extraction

Conversation

@Sheraff

@Sheraff Sheraff commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Improved route parsing for optional parameters and brace-based path segments.
    • Unclosed, empty, or unmatched parameter braces are now handled safely as static path text when appropriate.
  • Tests

    • Added coverage for invalid and edge-case optional path parameters.
  • Chores

    • Prepared a patch release for the router core package.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 00abefbd-897d-478e-81e1-c34f72afab3f

📥 Commits

Reviewing files that changed from the base of the PR and between 53b63cf and ab34f9c.

📒 Files selected for processing (3)
  • .changeset/fresh-bats-begin.md
  • packages/router-core/src/new-process-route-tree.ts
  • packages/router-core/tests/optional-path-params.test.ts

📝 Walkthrough

Walkthrough

parseSegment now detects opening and closing braces inline. New tests cover malformed optional-parameter syntax. A changeset records a patch release for @tanstack/router-core.

Changes

Route parser behavior

Layer / File(s) Summary
Inline brace parsing and malformed optional-parameter coverage
packages/router-core/src/new-process-route-tree.ts, packages/router-core/tests/optional-path-params.test.ts, .changeset/fresh-bats-begin.md
parseSegment performs brace detection without the standalone helper. Tests verify that unclosed, empty, and unmatched optional-parameter syntax remains static pathname content. A patch changeset documents the optimization.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to ab34f

This PR makes a localized parser performance change with accompanying tests and release notes; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: inlining brace extraction in router-core parseSegment.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf-router-core-parse-segment-inline-braces-extraction

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit ab34f9c

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 13m 22s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2m 14s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-14 16:20:59 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

1 package(s) bumped directly, 22 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/router-core 1.171.23 → 1.171.24 Changeset
@tanstack/react-router 1.170.28 → 1.170.29 Dependent
@tanstack/react-start 1.168.45 → 1.168.46 Dependent
@tanstack/react-start-client 1.168.26 → 1.168.27 Dependent
@tanstack/react-start-rsc 0.1.44 → 0.1.45 Dependent
@tanstack/react-start-server 1.167.33 → 1.167.34 Dependent
@tanstack/router-cli 1.167.29 → 1.167.30 Dependent
@tanstack/router-generator 1.167.29 → 1.167.30 Dependent
@tanstack/router-plugin 1.168.31 → 1.168.32 Dependent
@tanstack/router-vite-plugin 1.167.31 → 1.167.32 Dependent
@tanstack/solid-router 1.170.26 → 1.170.27 Dependent
@tanstack/solid-start 1.168.43 → 1.168.44 Dependent
@tanstack/solid-start-client 1.168.25 → 1.168.26 Dependent
@tanstack/solid-start-server 1.167.32 → 1.167.33 Dependent
@tanstack/start-client-core 1.170.23 → 1.170.24 Dependent
@tanstack/start-plugin-core 1.171.35 → 1.171.36 Dependent
@tanstack/start-server-core 1.169.27 → 1.169.28 Dependent
@tanstack/start-static-server-functions 1.167.28 → 1.167.29 Dependent
@tanstack/start-storage-context 1.167.25 → 1.167.26 Dependent
@tanstack/vue-router 1.170.25 → 1.170.26 Dependent
@tanstack/vue-start 1.168.42 → 1.168.43 Dependent
@tanstack/vue-start-client 1.167.28 → 1.167.29 Dependent
@tanstack/vue-start-server 1.167.32 → 1.167.33 Dependent

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: ca608f75a558
  • Measured at: 2026-08-14T16:04:48.688Z
  • Baseline source: history:53b63cf6fbec
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 83.88 KiB -12 B (-0.01%) 83.75 KiB 262.57 KiB 73.03 KiB ███▁▁▁▁▁▁▆▆▅
react-router.full 87.38 KiB -19 B (-0.02%) 87.24 KiB 274.29 KiB 76.03 KiB ██▇▁▁▁▁▁▂▅▅▃
solid-router.minimal 33.15 KiB -35 B (-0.10%) 33.03 KiB 96.23 KiB 29.88 KiB ███▂▂▂▃▄▄▄▄▁
solid-router.full 37.99 KiB -14 B (-0.04%) 37.86 KiB 110.86 KiB 34.25 KiB ███▁▁▁▂▂▂▂▂▁
vue-router.minimal 49.56 KiB -34 B (-0.07%) 49.43 KiB 138.40 KiB 44.74 KiB ▄▄▄▁▁▁█▇███▆
vue-router.full 55.17 KiB -34 B (-0.06%) 55.04 KiB 156.61 KiB 49.64 KiB ▄▄▄▁▁▁█████▇
react-start.minimal 96.69 KiB -33 B (-0.03%) 96.55 KiB 304.81 KiB 83.82 KiB ██▇▁▁▁▁▁▁▅▅▃
react-start.deferred-hydration 97.41 KiB -30 B (-0.03%) 96.57 KiB 306.17 KiB 84.47 KiB ██▇▁▁▁▁▁▁▅▅▄
react-start.full 99.87 KiB -23 B (-0.02%) 99.73 KiB 314.51 KiB 86.49 KiB ███▁▁▁▁▁▂▅▅▄
react-start.rsbuild.minimal 100.03 KiB -1 B (-0.00%) 99.86 KiB 315.22 KiB 86.30 KiB ███▁▁▁▁▁▁▅▅▅
react-start.rsbuild.full 103.35 KiB +2 B (+0.00%) 103.18 KiB 325.31 KiB 89.01 KiB ███▁▁▁▁▁▁▅▅▅
solid-start.minimal 45.93 KiB -24 B (-0.05%) 45.81 KiB 137.29 KiB 40.90 KiB ███▂▂▂▃▃▃▃▃▁
solid-start.deferred-hydration 48.99 KiB -39 B (-0.08%) 45.86 KiB 144.75 KiB 43.69 KiB ██▇▃▃▃▃▄▄▄▄▁
solid-start.full 51.02 KiB -19 B (-0.04%) 50.89 KiB 152.67 KiB 45.19 KiB ███▁▁▁▂▂▃▃▃▁
vue-start.minimal 65.62 KiB -20 B (-0.03%) 65.50 KiB 189.22 KiB 58.41 KiB ▄▄▄▁▁▁█████▇
vue-start.full 69.42 KiB -30 B (-0.04%) 69.29 KiB 201.53 KiB 61.67 KiB ▅▅▄▁▁▁█████▇

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@pkg-pr-new

pkg-pr-new Bot commented Aug 14, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8071

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8071

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8071

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8071

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@8071

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@8071

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@8071

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8071

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8071

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8071

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8071

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8071

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@8071

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@8071

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@8071

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@8071

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@8071

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@8071

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8071

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@8071

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8071

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@8071

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8071

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8071

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8071

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8071

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8071

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8071

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8071

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8071

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8071

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8071

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8071

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8071

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8071

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@8071

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8071

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8071

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8071

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8071

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8071

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8071

commit: ab34f9c

@codspeed-hq

codspeed-hq Bot commented Aug 14, 2026

Copy link
Copy Markdown

Merging this PR will regress 0 benchmarks

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 10 improved benchmarks
❌ 8 (👁 8) regressed benchmarks
✅ 162 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server request-churn (solid) 3,350.3 KB 713.4 KB ×4.7
Memory mem server error-paths unmatched (vue) 2,726.6 KB 592.4 KB ×4.6
Memory mem server request-churn (react) 2,254 KB 666.6 KB ×3.4
Memory mem server peak-large-page (solid) 1.5 MB 1.1 MB +28.57%
Memory mem server error-paths redirect (vue) 474.1 KB 405.3 KB +16.97%
Memory mem server error-paths redirect (react) 338.9 KB 300 KB +12.95%
Memory mem server server-fn-churn (react) 407.1 KB 364.5 KB +11.7%
Memory mem client navigation-churn (solid) 694.8 KB 664.7 KB +4.54%
Simulation client-control-flow navigation loop (react) 177.9 ms 171.1 ms +3.99%
Memory mem server aborted-requests (react) 885.9 KB 853.7 KB +3.78%
👁 Memory mem server error-paths not-found (solid) 574.5 KB 825.9 KB -30.44%
👁 Simulation client-nested-params navigation loop (react) 212.6 ms 228.7 ms -7.07%
👁 Memory mem server aborted-requests (vue) 1,010.2 KB 1,145.9 KB -11.84%
👁 Memory mem server error-paths not-found (vue) 463.5 KB 488.1 KB -5.04%
👁 Memory mem server serialization-payload (vue) 4.2 MB 4.4 MB -3.23%
👁 Memory mem server error-paths unmatched (react) 438.8 KB 907.6 KB -51.65%
👁 Memory mem server peak-large-page (react) 1.1 MB 1.2 MB -5.23%
👁 Memory mem client unique-location-churn (vue) 489.8 KB 540.3 KB -9.34%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing perf-router-core-parse-segment-inline-braces-extraction (ab34f9c) with main (53b63cf)

Open in CodSpeed

@Sheraff
Sheraff merged commit 4c89b15 into main Aug 14, 2026
26 checks passed
@Sheraff
Sheraff deleted the perf-router-core-parse-segment-inline-braces-extraction branch August 14, 2026 19:03
@github-actions github-actions Bot mentioned this pull request Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant