Made Compile.ps1 not load the script into memory and use -Raw#4536
Conversation
|
Whilst looking a bit simpler, switching out the Generic List Class for the simple "+=" could have quite some performance implications, so i would not recommend merging this. Native PowerShell Objects (Strings, Arrays etc) are often immutable by design, so calling += to add new data to them duplicates the object in memory, appends the new data, stores it as a new object and then drops the previous object. This is quite a slow and memory intensive process. In the newest PowerShell Versions the impact seems to be a bit reduced, but as Windows dosn't ship these versions by default, i still would keep the old logic for this. You can learn more about PowerShell performance quirks at: |
i just tested this in pwsh and powershell and it's about 30 mileseconds slower while having way better and more readable syntax |
|
Fair But we should consider if we want compromise on performance (even if the impact in this case is relatively little) when the only change needed in the code is a single line to setup the generic list and running $var.add() instead of $var += "something". The reduction in lines in your PR mostly stems from removing comments and line breaks. |
it's not about removing lines it's about making the code more understandable and i wouldn't want to compromise the performance of winutil but the complie.ps1 is a diffrent thing and not to long ago i made the complie.ps1 script go from taking a few seconds to 100 milesconds so i think it's fine to compromise the performance by so little |
Type of Change
Description
pr #2062 made complie.ps1 add winutil into memory instead of constantly using
| Out-Filewhich made sense but it's simpler and more strightforward to use$script +=Using
-Rawmakes this about 6 times faster from 120 mileseconds to 20 mileseconds so the "performance lost" from not usingCollections.Generic.Listdosen't matterofc i tested this :)