Consider replacing `foreach` on IList/List with `for` loop
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- performance
Research direction
Start with the foreach loops linked in Parser/TSql/TSql150Parser.cs around lines 89 and 115. Then inspect tools/AstGen/ClassDescription.cs around lines 249 and 260, including the IEnumerable cast and child iteration, and trace the generated code for additional IList loops. Done means eligible IList/List iteration uses indexed access without changing parser behavior or generated output.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- GAP
- Stars
- 277
- Forks
- 43
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/SqlScriptDOM
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
microsoft/SqlScriptDOM#228 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/SqlScriptDOM#183 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 56/100
microsoft/SqlScriptDOM#226 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
microsoft/SqlScriptDOM#225 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
microsoft/SqlScriptDOM#224 ·
All issues in microsoft/SqlScriptDOM
Similar issues
-
todo:perf
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tenstorrent/tt-metal#57320 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
mlcommons/mobile_app_open#1182 ·
-
[bug] skill review is quadratic in unmatched markdown brackets: a 64 KiB file of '[' takes 9.2 s Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100