Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions src/SwaggerProvider.Runtime/RuntimeHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,32 @@ type TaskExtensions() =
}

module RuntimeHelpers =
let inline private toStrArray name values =
values
|> Array.map(fun value -> name, value.ToString())
|> Array.toList
// Builds the (name, str) list directly in a single backward pass over the array,
// avoiding the intermediate array allocation that `Array.map |> Array.toList` would
// otherwise produce (this runs once per array-typed query/path/header parameter).
let inline private toStrArray name (values: 'a[]) =
let mutable acc = []

for i in values.Length - 1 .. -1 .. 0 do
acc <- (name, values[i].ToString()) :: acc

acc

let inline private toStrArrayDateTime name (values: DateTime array) =
values
|> Array.map(fun value -> name, value.ToString("O"))
|> Array.toList
let mutable acc = []

for i in values.Length - 1 .. -1 .. 0 do
acc <- (name, values[i].ToString("O")) :: acc

acc

let inline private toStrArrayDateTimeOffset name (values: DateTimeOffset array) =
values
|> Array.map(fun value -> name, value.ToString("O"))
|> Array.toList
let mutable acc = []

for i in values.Length - 1 .. -1 .. 0 do
acc <- (name, values[i].ToString("O")) :: acc

acc

let inline private toStrArrayOpt name values =
values |> Array.choose(id) |> toStrArray name
Expand Down
Loading