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

Open Beginner friendly
#11,037 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
powershell
Domain
documentation

Research direction

Edit reference/docs-conceptual/dev-cross-plat/performance/script-authoring-considerations.md, linked from the reported Performance Considerations page. Start by reading the existing performance guidance and the referenced Stack Overflow answers, then add a section covering why function or scriptblock recursion should be avoided and the Stack or Queue approach. Done means the requested guidance is present in the document.

Written by the indexing model from the issue text.

Description

area-sdk-docs
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

Dominant language
PowerShell
Stars
2.5k
Forks
1.7k
Avg merge
8h 45m
Merged PRs (30d)
33

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MicrosoftDocs/PowerShell-Docs

All issues in MicrosoftDocs/PowerShell-Docs

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.