Skip to content

[repo-assist] perf: add float32/double/Guid fast-paths in toParam; replace String.Format with interpolation#443

Merged
sergey-tihon merged 2 commits into
masterfrom
repo-assist/improve-toparam-fastpaths-20260518-f3b69f88aff63be0
May 19, 2026
Merged

[repo-assist] perf: add float32/double/Guid fast-paths in toParam; replace String.Format with interpolation#443
sergey-tihon merged 2 commits into
masterfrom
repo-assist/improve-toparam-fastpaths-20260518-f3b69f88aff63be0

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Two focused improvements to the runtime layer:

1. Fast-paths for float32, double, and Guid in toParam

toParam already has fast-path match arms for string, int32, int64, and bool that avoid the expensive generic branch (a GetType() call plus up to four subsequent type checks: FullName × 2, IsGenericType, IsEnum). This PR adds the same treatment for three more common OpenAPI scalar types:

Type OpenAPI format Notes
float32 number (default) Most common numeric type for non-integer fields
double number / double Second numeric type
Guid string / uuid Very common identifier type in REST APIs

All three produce the same output as the generic obj.ToString() fallback — the change is purely in the code path taken, not the result.

2. Replace two remaining String.Format calls with string interpolation

For consistency with the rest of the codebase (all other format sites already use $"{...}"):

  • RuntimeHelpers.fillHeaders error message: String.Format("Cannot add header '{0}'='{1}' ...", name, value)$"Cannot add header '{name}'='{value}' ..."
  • OperationCompiler cookie header builder (inside quotation): String.Format("{0}={1}", name, value)$"{name}={value}"

Test Status

All 425 unit tests pass. The existing tests for float32, double, and Guid (added in #442) now exercise the new fast-paths.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@79c99dfd73f3b7ad8ab2b0f4944838018dbe4736

…ormat with interpolation

Add three new fast-path match arms to toParam before the expensive
generic branch (which calls GetType() plus up to four type checks):

- float32 / double: skip GetType() + IsGenericType + IsEnum checks
  for the two floating-point scalar types that are common in number-
  heavy OpenAPI schemas.
- Guid: skip GetType() + FullName comparisons for the uuid format,
  which is one of the most frequent identifier types in OpenAPI APIs.

All three fast-paths produce the same output as the generic fallback
(obj.ToString()) since none of them need special formatting.

Also replace the two remaining String.Format calls with string
interpolation for consistency with the rest of the codebase:
- RuntimeHelpers.fillHeaders error message
- OperationCompiler cookie header builder inside quotation

All 425 existing unit tests continue to pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sergey-tihon sergey-tihon marked this pull request as ready for review May 18, 2026 20:26
Copilot AI review requested due to automatic review settings May 18, 2026 20:26

Copilot AI 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.

Pull request overview

This PR makes small runtime/design-time formatting optimizations in SwaggerProvider by adding direct scalar serialization paths and replacing remaining String.Format usages with interpolation.

Changes:

  • Adds float32, double, and Guid fast paths in RuntimeHelpers.toParam.
  • Replaces String.Format in header error construction and cookie header generation with interpolated strings.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/SwaggerProvider.Runtime/RuntimeHelpers.fs Adds scalar toParam fast paths and updates header error formatting.
src/SwaggerProvider.DesignTime/OperationCompiler.fs Updates generated cookie header formatting to use interpolation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sergey-tihon sergey-tihon merged commit b37aea9 into master May 19, 2026
6 checks passed
@sergey-tihon sergey-tihon deleted the repo-assist/improve-toparam-fastpaths-20260518-f3b69f88aff63be0 branch May 19, 2026 06:05
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.

2 participants