Skip to content

perf: use slice for proven ordered bounds - #7977

Draft
Sheraff wants to merge 4 commits into
mainfrom
codex/shorter-string-operations
Draft

perf: use slice for proven ordered bounds#7977
Sheraff wants to merge 4 commits into
mainfrom
codex/shorter-string-operations

Conversation

@Sheraff

@Sheraff Sheraff commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replace 24 internal substring calls with shorter slice calls only where both bounds are proven non-negative and ordered.

The five extraction sites whose bounds can reverse remain substring; focused tests cover overlapping named, optional, and wildcard affixes plus Unicode lowercase expansion. No public API or browser-support floor changes.

Bundle impact

Measured from clean commit ae8b0397cf0a6813ea380fae4903371fd5d83ae5 against exact main base 697ebb6ddbd433d052b6b4707938a5c595865d58:

  • all 17 scenarios improve total gzip by 2–23 bytes
  • raw size improves by 84–88 bytes in every scenario
  • one initial-gzip metric regresses by 3 bytes; mixed Brotli results are disclosed in the checked-in report
  • no imports, helpers, exports, or tree-shaking boundaries change

A nearby indexOfincludes group was dropped after its isolated performance result was not confidently neutral.

Performance and validation

  • direct ordered-bound benchmark: slice averages 10.34% faster than substring across four final runs
  • real API benchmarks are flat to positive except a noisy search-prefix case with alternating paired direction
  • router-core path suite: 361/361 passed with no type errors
  • package unit, type, and lint validation passed for history, router-core, React Router, and Solid Router
  • five independent semantic, compatibility, performance, tree-shaking, test, and measurement reviews approved the clean final diff

Full attribution, matrix, performance results, and rejected variants are in RESULT-optimization-shorter-string-operations.md.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e9a465b8-5741-4b21-83aa-30b0dee47c78

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 6, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit ae8b039

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 11m 29s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-06 07:36:41 UTC

@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: ae8b039

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: d17f90f9165b
  • Measured at: 2026-08-06T03:10:54.367Z
  • Baseline source: history:697ebb6ddbd4
  • 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 87.10 KiB -12 B (-0.01%) 86.96 KiB 269.05 KiB 75.81 KiB ████▂▂▂▂▂▁▂▁
react-router.full 90.89 KiB -7 B (-0.01%) 90.75 KiB 281.00 KiB 79.07 KiB ████▂▂▂▂▂▁▂▂
solid-router.minimal 34.79 KiB -11 B (-0.03%) 34.66 KiB 99.88 KiB 31.41 KiB ████▂▂▂▂▂▁▁▁
solid-router.full 39.90 KiB -2 B (-0.00%) 39.77 KiB 115.06 KiB 35.91 KiB ████▂▂▂▂▂▁▁▁
vue-router.minimal 52.09 KiB -8 B (-0.01%) 51.96 KiB 143.04 KiB 46.86 KiB ████▁▁▁▁▁▁▁▁
vue-router.full 58.04 KiB -8 B (-0.01%) 57.91 KiB 161.71 KiB 52.07 KiB ████▁▁▁▁▁▁▁▁
react-start.minimal 100.58 KiB -14 B (-0.01%) 100.45 KiB 312.20 KiB 87.30 KiB ███████▁▁▁▁▁
react-start.deferred-hydration 101.32 KiB -14 B (-0.01%) 100.47 KiB 313.57 KiB 88.13 KiB ███████▁▁▁▁▁
react-start.full 103.92 KiB -2 B (-0.00%) 103.78 KiB 322.15 KiB 90.23 KiB ███████▁▁▁▁▁
react-start.rsbuild.minimal 100.22 KiB -13 B (-0.01%) 100.05 KiB 316.70 KiB 86.40 KiB ▁▁▁▁▂▂▂█████
react-start.rsbuild.minimal-iife 100.63 KiB -13 B (-0.01%) 100.47 KiB 317.63 KiB 86.78 KiB ▁▁▁▁▂▂▂█████
react-start.rsbuild.full 103.56 KiB -12 B (-0.01%) 103.39 KiB 326.79 KiB 89.21 KiB ▁▁▁▁▃▃▃█████
solid-start.minimal 48.17 KiB -12 B (-0.02%) 48.04 KiB 142.02 KiB 42.80 KiB ███████▁▁▁▁▁
solid-start.deferred-hydration 51.43 KiB -10 B (-0.02%) 48.10 KiB 150.06 KiB 45.85 KiB ███████▁▁▁▁▁
solid-start.full 53.42 KiB -17 B (-0.03%) 53.29 KiB 157.75 KiB 47.28 KiB ████▆▆▆▁▁▁▁▁
vue-start.minimal 68.95 KiB -23 B (-0.03%) 68.82 KiB 195.03 KiB 61.28 KiB ████▆▆▆▁▁▁▁▁
vue-start.full 72.92 KiB -8 B (-0.01%) 72.79 KiB 207.53 KiB 64.74 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.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

5 package(s) bumped directly, 18 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.170.20 → 1.170.21 Changeset
@tanstack/router-core 1.171.17 → 1.171.18 Changeset
@tanstack/solid-router 1.170.20 → 1.170.21 Changeset
@tanstack/start-server-core 1.169.20 → 1.169.21 Changeset
@tanstack/vue-router 1.170.19 → 1.170.20 Changeset
@tanstack/react-start 1.168.37 → 1.168.38 Dependent
@tanstack/react-start-client 1.168.18 → 1.168.19 Dependent
@tanstack/react-start-rsc 0.1.36 → 0.1.37 Dependent
@tanstack/react-start-server 1.167.25 → 1.167.26 Dependent
@tanstack/router-cli 1.167.23 → 1.167.24 Dependent
@tanstack/router-generator 1.167.23 → 1.167.24 Dependent
@tanstack/router-plugin 1.168.25 → 1.168.26 Dependent
@tanstack/router-vite-plugin 1.167.25 → 1.167.26 Dependent
@tanstack/solid-start 1.168.36 → 1.168.37 Dependent
@tanstack/solid-start-client 1.168.18 → 1.168.19 Dependent
@tanstack/solid-start-server 1.167.25 → 1.167.26 Dependent
@tanstack/start-client-core 1.170.16 → 1.170.17 Dependent
@tanstack/start-plugin-core 1.171.28 → 1.171.29 Dependent
@tanstack/start-static-server-functions 1.167.21 → 1.167.22 Dependent
@tanstack/start-storage-context 1.167.19 → 1.167.20 Dependent
@tanstack/vue-start 1.168.35 → 1.168.36 Dependent
@tanstack/vue-start-client 1.167.21 → 1.167.22 Dependent
@tanstack/vue-start-server 1.167.25 → 1.167.26 Dependent

@codspeed-hq

codspeed-hq Bot commented Aug 6, 2026

Copy link
Copy Markdown

Merging this PR will regress 6 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

⚡ 6 improved benchmarks
❌ 6 regressed benchmarks
✅ 168 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server request-churn (solid) 425.2 KB 2,908.5 KB -85.38%
Memory mem server error-paths redirect (vue) 338.6 KB 524.8 KB -35.48%
Memory mem client unique-location-churn (solid) 341.2 KB 455.5 KB -25.08%
Memory mem server error-paths unmatched (react) 317.5 KB 356.9 KB -11.04%
Memory mem client unique-location-churn (react) 665 KB 718.9 KB -7.5%
Memory mem client navigation-churn (solid) 580.3 KB 619.9 KB -6.4%
Memory mem server server-fn-churn (vue) 4,147.3 KB 270.5 KB ×15
Memory mem server error-paths unmatched (vue) 2,142.1 KB 479.1 KB ×4.5
Memory mem server peak-large-page (react) 1,737.5 KB 953.7 KB +82.19%
Memory mem server error-paths redirect (solid) 388 KB 278.6 KB +39.29%
Memory mem client navigation-churn (vue) 1.3 MB 1.2 MB +3.9%
Simulation ssr control-flow unmatched 404 (react) 58.1 ms 56.1 ms +3.59%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing codex/shorter-string-operations (ae8b039) with main (697ebb6)

Open in CodSpeed

@nx-cloud nx-cloud Bot 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.

Nx Cloud has identified a possible root cause for your failed CI:

We classified this failure as an environment issue unrelated to the PR. The error originates in a stale e2e-utils dist artifact missing the toRuntimePath export — a build environment problem entirely outside the scope of the substringslice optimization changes in @tanstack/router-core. No changes to this PR are needed to resolve it.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

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