Browse Source

Merge pull request #1328 from SixLabors/js/chunk-bump

Bump ChunkedMemoryStream buffer length
pull/1574/head
James Jackson-South 6 years ago
committed by GitHub
parent
commit
d908477519
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      .github/workflows/build-and-test.yml
  2. 2
      README.md
  3. 17
      src/ImageSharp/IO/ChunkedMemoryStream.cs

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

@ -52,11 +52,6 @@ jobs:
git fetch --prune --unshallow
git submodule -q update --init --recursive
- name: Setup DotNet SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: "3.1.x"
- name: Build
shell: pwsh
run: ./ci-build.ps1 "${{matrix.options.framework}}"
@ -95,11 +90,6 @@ jobs:
git fetch --prune --unshallow
git submodule -q update --init --recursive
- name: Setup DotNet SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: "3.1.x"
- name: Pack
shell: pwsh
run: ./ci-pack.ps1

2
README.md

@ -49,7 +49,7 @@ Install stable releases via Nuget; development releases are available via MyGet.
| Package Name | Release (NuGet) | Nightly (MyGet) |
|--------------------------------|-----------------|-----------------|
| `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) |
| `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) |
## Manual build

17
src/ImageSharp/IO/ChunkedMemoryStream.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.IO
/// <summary>
/// The default length in bytes of each buffer chunk.
/// </summary>
public const int DefaultBufferLength = 81920;
public const int DefaultBufferLength = 128 * 1024;
// The memory allocator.
private readonly MemoryAllocator allocator;
@ -238,7 +238,9 @@ namespace SixLabors.ImageSharp.IO
Guard.NotNull(buffer, nameof(buffer));
Guard.MustBeGreaterThanOrEqualTo(offset, 0, nameof(offset));
Guard.MustBeGreaterThanOrEqualTo(count, 0, nameof(count));
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), $"{offset} subtracted from the buffer length is less than {count}");
const string BufferMessage = "Offset subtracted from the buffer length is less than count.";
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), BufferMessage);
return this.ReadImpl(buffer.AsSpan().Slice(offset, count));
}
@ -348,7 +350,16 @@ namespace SixLabors.ImageSharp.IO
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void Write(byte[] buffer, int offset, int count)
=> this.WriteImpl(buffer.AsSpan().Slice(offset, count));
{
Guard.NotNull(buffer, nameof(buffer));
Guard.MustBeGreaterThanOrEqualTo(offset, 0, nameof(offset));
Guard.MustBeGreaterThanOrEqualTo(count, 0, nameof(count));
const string BufferMessage = "Offset subtracted from the buffer length is less than count.";
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), BufferMessage);
this.WriteImpl(buffer.AsSpan().Slice(offset, count));
}
#if SUPPORTS_SPAN_STREAM
/// <inheritdoc/>

Loading…
Cancel
Save