Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Avoid function / scriptblock based recursion" section to Performance Considerations document #11037

Open
iRon7 opened this issue Apr 20, 2024 · 0 comments
Labels
area-sdk-docs Area - SDK docs

Comments

@iRon7
Copy link
Contributor

iRon7 commented Apr 20, 2024

Type of issue

Missing information

Feedback

Knowing that PowerShell functions are quite expensive (see: https://stackoverflow.com/a/75722847/1701026) it is better to avoid recursion as per helpful StackOverflow answer from @santisq:

The recommended approach would be to traverse your nested objects using a Stack or Queue (or their generic counterparts Stack<T> and Queue<T>).

Page URL

https://learn.microsoft.com/en-us/powershell/scripting/dev-cross-plat/performance/script-authoring-considerations?view=powershell-7.4

Content source URL

https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/docs-conceptual/dev-cross-plat/performance/script-authoring-considerations.md

Author

@sdwheeler

Document Id

9818d91b-8c5f-337a-f5e1-7a40abd5fd1a

@iRon7 iRon7 added the needs-triage Waiting - Needs triage label Apr 20, 2024
@iRon7 iRon7 changed the title Add "Avoid function / scriptblock based recursion" section to `Performance Considerations" Add "Avoid function / scriptblock based recursion" section to Performance Considerations document Apr 20, 2024
@sdwheeler sdwheeler added area-sdk-docs Area - SDK docs and removed needs-triage Waiting - Needs triage labels Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-sdk-docs Area - SDK docs
Projects
None yet
Development

No branches or pull requests

2 participants