diff options
author | Marcos Casagrande <marcoscvp90@gmail.com> | 2020-04-26 22:29:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-26 16:29:51 -0400 |
commit | 128dce0d8a2ae062d0d85918da841a6f6aa2198a (patch) | |
tree | 014465ed774565e6d977b8ca3ed7ab2cb7daae34 /std/io/ioutil.ts | |
parent | 49cad79fb1f908131db2a7918f97b6d2e6275f90 (diff) |
Increase copyN buffer size to match go implementation (#4904)
Diffstat (limited to 'std/io/ioutil.ts')
-rw-r--r-- | std/io/ioutil.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/std/io/ioutil.ts b/std/io/ioutil.ts index 9a727f436..8c30ae566 100644 --- a/std/io/ioutil.ts +++ b/std/io/ioutil.ts @@ -4,6 +4,8 @@ type Reader = Deno.Reader; type Writer = Deno.Writer; import { assert } from "../testing/asserts.ts"; +const DEFAULT_BUFFER_SIZE = 32 * 1024; + /** copy N size at the most. * If read size is lesser than N, then returns nread * */ @@ -13,9 +15,9 @@ export async function copyN( size: number ): Promise<number> { let bytesRead = 0; - let buf = new Uint8Array(1024); + let buf = new Uint8Array(DEFAULT_BUFFER_SIZE); while (bytesRead < size) { - if (size - bytesRead < 1024) { + if (size - bytesRead < DEFAULT_BUFFER_SIZE) { buf = new Uint8Array(size - bytesRead); } const result = await r.read(buf); |