Skip to content

Commit 801961d

Browse files
Merge pull request #1328 from SixLabors/js/chunk-bump
Bump ChunkedMemoryStream buffer length
2 parents d95a996 + ff265ab commit 801961d

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

.github/workflows/build-and-test.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ jobs:
5252
git fetch --prune --unshallow
5353
git submodule -q update --init --recursive
5454
55-
- name: Setup DotNet SDK
56-
uses: actions/setup-dotnet@v1
57-
with:
58-
dotnet-version: "3.1.x"
59-
6055
- name: Build
6156
shell: pwsh
6257
run: ./ci-build.ps1 "${{matrix.options.framework}}"
@@ -95,11 +90,6 @@ jobs:
9590
git fetch --prune --unshallow
9691
git submodule -q update --init --recursive
9792
98-
- name: Setup DotNet SDK
99-
uses: actions/setup-dotnet@v1
100-
with:
101-
dotnet-version: "3.1.x"
102-
10393
- name: Pack
10494
shell: pwsh
10595
run: ./ci-pack.ps1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Install stable releases via Nuget; development releases are available via MyGet.
4949

5050
| Package Name | Release (NuGet) | Nightly (MyGet) |
5151
|--------------------------------|-----------------|-----------------|
52-
| `SixLabors.ImageSharp` | [![NuGet](https://img.shields.io/nuget/v/SixLabors.ImageSharp.svg)](https://www.nuget.org/packages/SixLabors.ImageSharp/) | [![MyGet](https://img.shields.io/myget/sixlabors/v/SixLabors.ImageSharp.svg)](https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.ImageSharp) |
52+
| `SixLabors.ImageSharp` | [![NuGet](https://img.shields.io/nuget/v/SixLabors.ImageSharp.svg)](https://www.nuget.org/packages/SixLabors.ImageSharp/) | [![MyGet](https://img.shields.io/myget/sixlabors/vpre/SixLabors.ImageSharp.svg)](https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.ImageSharp) |
5353

5454
## Manual build
5555

src/ImageSharp/IO/ChunkedMemoryStream.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal sealed class ChunkedMemoryStream : Stream
1818
/// <summary>
1919
/// The default length in bytes of each buffer chunk.
2020
/// </summary>
21-
public const int DefaultBufferLength = 81920;
21+
public const int DefaultBufferLength = 128 * 1024;
2222

2323
// The memory allocator.
2424
private readonly MemoryAllocator allocator;
@@ -238,7 +238,9 @@ public override int Read(byte[] buffer, int offset, int count)
238238
Guard.NotNull(buffer, nameof(buffer));
239239
Guard.MustBeGreaterThanOrEqualTo(offset, 0, nameof(offset));
240240
Guard.MustBeGreaterThanOrEqualTo(count, 0, nameof(count));
241-
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), $"{offset} subtracted from the buffer length is less than {count}");
241+
242+
const string BufferMessage = "Offset subtracted from the buffer length is less than count.";
243+
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), BufferMessage);
242244

243245
return this.ReadImpl(buffer.AsSpan().Slice(offset, count));
244246
}
@@ -348,7 +350,16 @@ public override int ReadByte()
348350
/// <inheritdoc/>
349351
[MethodImpl(MethodImplOptions.AggressiveInlining)]
350352
public override void Write(byte[] buffer, int offset, int count)
351-
=> this.WriteImpl(buffer.AsSpan().Slice(offset, count));
353+
{
354+
Guard.NotNull(buffer, nameof(buffer));
355+
Guard.MustBeGreaterThanOrEqualTo(offset, 0, nameof(offset));
356+
Guard.MustBeGreaterThanOrEqualTo(count, 0, nameof(count));
357+
358+
const string BufferMessage = "Offset subtracted from the buffer length is less than count.";
359+
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), BufferMessage);
360+
361+
this.WriteImpl(buffer.AsSpan().Slice(offset, count));
362+
}
352363

353364
#if SUPPORTS_SPAN_STREAM
354365
/// <inheritdoc/>

0 commit comments

Comments
 (0)