Skip to content

Commit cdee804

Browse files
Copilotxperiandri
andcommitted
Minor optimization: avoid sprintf in character loop for better performance
Agent-Logs-Url: https://github.com/fsprojects/FSharp.Data.GraphQL/sessions/ce0fba11-9043-452f-b948-e03c8b644f26 Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
1 parent 93db5f8 commit cdee804

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/FSharp.Data.GraphQL.Shared/AstExtensions.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ type Document with
117117
| '\n' -> "\\n"
118118
| '\r' -> "\\r"
119119
| '\t' -> "\\t"
120-
| c when c < '\u0020' -> sprintf "\\u%04X" (int c)
120+
| c when c < '\u0020' ->
121+
let hex = (int c).ToString("X4", CultureInfo.InvariantCulture)
122+
"\\u" + hex
121123
| c -> string c
122124
escaped.Append(appendStr) |> ignore
123125
escaped.Append('"').ToString()

0 commit comments

Comments
 (0)