Skip to content

Commit

Permalink
Improve performance on json to psobject conversion (PowerShell#7482)
Browse files Browse the repository at this point in the history
This amounts so a speed-up in the order of 7x. Cmdlets that benefit from this are `Convertfrom-Json` and `Invoke-RestMethod`. There are three main changes:

- Convert from `JArray` directly to object array instead of creating a `List` and do `list.ToArray()`.
- Avoid iterating through `PSObject.Properties` to check for existing members, since that is a very slow and allocation heavy code path.
- Pre-allocate the members in `PSObject` by using the newly added constructor accepting an initial member count.
  • Loading branch information
powercode authored and daxian-dbw committed Aug 10, 2018
1 parent 3aaa181 commit 1243891
Showing 1 changed file with 158 additions and 157 deletions.
Loading

0 comments on commit 1243891

Please sign in to comment.