Skip to content

Commit 4e72c55

Browse files
perf: reduce allocations in appendSection and increase stream copy buffer size
- Replace list-based underline creation with String('-', n) constructor to eliminate unnecessary list/array allocations in appendSection - Increase stream copy buffer from 1024 to 81920 bytes (matching .NET default for Stream.CopyToAsync) to improve download throughput Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6d6b85f commit 4e72c55

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/FsHttp/Helper.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ type StringBuilder with
2626

2727
member sb.appendSection(s: string) =
2828
sb.appendLine s
29-
30-
String([ 0 .. s.Length ] |> List.map (fun _ -> '-') |> List.toArray)
31-
|> sb.appendLine
29+
String('-', s.Length + 1) |> sb.appendLine
3230

3331
[<RequireQualifiedAccess>]
3432
module Map =
@@ -96,7 +94,7 @@ module Stream =
9694

9795
let copyToCallbackAsync (target: Stream) callback (source: Stream) =
9896
async {
99-
let buffer = Array.create 1024 (byte 0)
97+
let buffer = Array.create 81920 (byte 0)
10098
let logTimeSpan = TimeSpan.FromSeconds 1.5
10199
let mutable continueLooping = true
102100
let mutable overallBytesCount = 0

0 commit comments

Comments
 (0)