Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Consider replacing `foreach` on IList/List with `for` loop

オープン
#138 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp
領域
performance

調査の方向性

Parser/TSql/TSql150Parser.cs の 89 行目と 115 行目付近にある foreach ループから始めます。次に tools/AstGen/ClassDescription.cs の 249 行目と 260 行目付近を調べ、IEnumerable へのキャストと子要素の反復処理を含めて確認し、生成されたコードをたどって追加の IList ループを探します。IList/List の対象となる反復処理が、パーサーの動作や生成される出力を変更せずにインデックスアクセスを使用すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

When parsing thousands of scripts foreach approach generates at least N * 2 unnecessary enumerators, e.g. in TSQL160Parser here and here.

Also somewhere in the deep of generated code it produces lots (~N*10) of enumerators on IList<Identifier> but I was unable to locate this place. It'd be great if this was fixed too.

Also please take a look at this IEnumerable implicit cast wherease the source is List and some code addressing this IEnumerable with foreach could be actually rewritten into more optimal for. And there is another suspicious foreach a couple of lines below which may affect iterating through children objects. Perhaps it will work faster and with less garbage objects for GC if implemented as for loop and index-based access to IList elements.

主要言語
GAP
スター
277
フォーク
43
平均マージ
6日 17時間
マージ済み PR(30日)
3

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/SqlScriptDOM のほかの issue

microsoft/SqlScriptDOM の issue をすべて見る

似ている issue

Performance の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。