From 86b32853491e19d88b056e10b091570129a2a166 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Mon, 31 Aug 2026 00:32:56 +0000
Subject: [PATCH] perf: avoid sprintf overhead for no-arg format strings in
HtmlFormatting
Replace sprintf "
" with a plain string literal in three
call sites within the hot code/output block rendering path. sprintf
with zero format specifiers still incurs printf-format parsing
overhead on every call; a plain literal avoids that with no behavior
change.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
RELEASE_NOTES.md | 3 +++
src/FSharp.Formatting.Markdown/HtmlFormatting.fs | 6 +++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index db104a87d..cc2db45bf 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -2,6 +2,9 @@
## [Unreleased]
+### Changed
+* Replace `sprintf ""` (a format string with no format arguments) with the plain string literal `""` in `HtmlFormatting.fs`. This is on the hot path invoked once per rendered code/output block, and avoids the unnecessary printf-format parsing overhead for a string with no substitutions.
+
### Removed
* Remove `docs/Dockerfile` (used for mybinder.org Binder integration) and mybinder badge links from documentation pages. The Binder integration relied on a deprecated .NET 7 SDK image and a deprecated `Microsoft.dotnet-interactive` version; mybinder.org support is discontinued.
* Remove `.ipynb` (Jupyter Notebook) "run in notebook" badge links from all documentation pages and delete `docs/img/badge-notebook.svg`. The links linked to `.ipynb` outputs generated by fsdocs, but .NET Interactive (which powered those notebooks) is deprecated and has no current replacement. The `.ipynb` output format itself is unchanged.
diff --git a/src/FSharp.Formatting.Markdown/HtmlFormatting.fs b/src/FSharp.Formatting.Markdown/HtmlFormatting.fs
index 0a2f56d25..0f32082fe 100644
--- a/src/FSharp.Formatting.Markdown/HtmlFormatting.fs
+++ b/src/FSharp.Formatting.Markdown/HtmlFormatting.fs
@@ -203,7 +203,7 @@ let rec internal formatParagraph (ctx: FormattingContext) paragraph =
ctx.Writer.Write("")
if String.IsNullOrWhiteSpace(language) then
- ctx.Writer.Write(sprintf "")
+ ctx.Writer.Write("")
else
let langCode = sprintf "language-%s" (htmlEncodeQuotes language)
ctx.Writer.Write(sprintf "" langCode)
@@ -218,7 +218,7 @@ let rec internal formatParagraph (ctx: FormattingContext) paragraph =
if ctx.WrapCodeSnippets then
ctx.Writer.Write("")
- ctx.Writer.Write(sprintf "")
+ ctx.Writer.Write("")
ctx.Writer.Write(htmlEncode code)
ctx.Writer.Write(" ")
@@ -315,7 +315,7 @@ let rec internal formatParagraph (ctx: FormattingContext) paragraph =
if ctx.WrapCodeSnippets then
ctx.Writer.Write("")
- ctx.Writer.Write(sprintf "")
+ ctx.Writer.Write("")
for (code, _) in lines do
ctx.Writer.Write(htmlEncode code)
|
|
|