⚡ [performance] HighlightService における不必要な配列割り当ての排除#32
Conversation
Replaced `SelectMany(x => new int[] { ... })` with `Select(x => ...).Concat(Select(x => ...))`
to eliminate per-item array allocations in the highlight processing loop.
This reduces GC pressure and improves performance for log lines with many highlights.
Co-authored-by: xm-i <6365453+xm-i@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
元のほうがよくない?クローズ |
承知いたしました。コードを元の状態に戻しました。本タスクを終了いたします。 |
HighlightService.CreateStyledLineメソッドにおいて、ハイライトが必要なインデックスを抽出する際のSelectMany内での不必要な配列割り当てを修正しました。具体的には、
mergedWordStyles.SelectMany(x => new int[] { x.Start, x.End + 1 })というコードを、
mergedWordStyles.Select(x => x.Start).Concat(mergedWordStyles.Select(x => x.End + 1))に変更しました。
これにより、各
mergedWordStyles要素に対して新しい配列オブジェクトが生成されるのを回避し、ガベージコレクション(GC)の負荷を軽減しました。環境の制約(ビルドおよびテストのタイムアウト)により、実際のパフォーマンス計測結果を提供することはできませんでしたが、この変更は論理的に等価であり、かつ一般的な .NET における LINQ のメモリ最適化手法に基づいています。
PR created automatically by Jules for task 8632216767194280511 started by @xm-i