Add ArrayPoolBufferWriter<T>.ResetWrittenCount()
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 42/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- csharp
- 領域
- performance
調査の方向性
ArrayPoolBufferWriter の実装と既存のテストを見つけてください。Issue に記載されている ResetWrittenCount() の public な動作を追加し、プールされたバッファーをクリアまたは置き換えることなく書き込み済みカウントがリセットされることを確認して、関連するテストスイートを実行してください。
索引モデルが issue の本文から書いたものです。
説明
Overview
The System.Buffers.ArrayBufferWriter<T> class has a ResetWrittenCount method, which resets the write position to zero without clearing the buffer, thus allowing a writer to be reused without clearing the buffer. Without this method, we must create a new ArrayPoolBufferWriter<T> instance each time, which carries the GC overhead of allocating the new object, but also the overhead of returning the buffer to the pool, only to immediately get it back again.
API breakdown
namespace CommunityToolkit.HighPerformance.Buffers;
public sealed class ArrayPoolBufferWriter<T> : IBuffer<T>, IMemoryOwner<T>
{
public void ResetWrittenCount() => index = 0;
}
Usage example
using var buffer = new ArrayPoolBufferWriter<byte>();
using var jsonWriter = new Utf8JsonWriter(buffer);
for (var i = 0; i < 100; i++)
{
// Serialize JSON into buffer.
JsonSerializer.Serialize(jsonWriter, obj, _jsonOptions);
// Compress JSON into output buffer.
compressionStream.Write(buffer.WrittenSpan);
// Reset the JSON writer and buffer.
buffer.ResetWrittenCount();
jsonWriter.Reset();
}
Breaking change?
No
Alternatives
There is no way to reuse the buffer without incurring the cost of clearing the buffer or cycling the buffer through the array pool.
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item
- 主要言語
- C#
- スター
- 3.8k
- フォーク
- 401
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CommunityToolkit/dotnet のほかの issue
-
RelayCommand<T>.CanExecute(null) returns false for value types without a predicate対応中かも @apachezy が 86 日前に担当しました。 オープンbug :bug:
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
CommunityToolkit/dotnet#1206 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
CommunityToolkit/dotnet#1186 ·
-
bug :bug:
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
CommunityToolkit/dotnet#648 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
CommunityToolkit/dotnet#1217 ·
-
bug :bug:
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
CommunityToolkit/dotnet#1215 ·
CommunityToolkit/dotnet の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
KnifeLemon/Filee#294 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
gavin-wolfe/wolfden#104 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] Still libmicrohttpd dependency is not removed properly from External-Dependency-Info.txt fileオープンtype/bug
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
area:framework
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[辞書] かんそうりつ->乾燥率オープン辞書
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信