Delete arguments in a ```Command``` structure

Hi all,

I didn't find a way to delete the arguments after being added to Command struct. Is the only way to recreate a new Command struct ? In case of a repetitive usage of such a command, is it worthwhile to reuse it to avoid incurring creating such a command each time ?

Thanks a lot for your help.

That's correct.

I can't imagine it takes a ton of time relative to spinning up a new external process generally, but it does allocate memory and whatnot. You'll have to measure it to see if it's worth it in your use case.

Maybe it could be worthwhile to add the possibility to delete arguments ?

Perhaps you could create a function that returns you a 'common' Command struct, then add some additional use case specific args on top. If you're just trying to reduce boilerplate.
A command is a seperate process (ish) so it doesnt really make sense that you could delete an argument after spinning it off, its running somewhere.
Have you measured the performance impact of creating a command? In my opinion you should optimise late and target the bottlenecks, rather than waste a lot of brain time on things the compiler will sort for you, or indeed which are not your bottleneck.

@amateur No I didn't really measure, that what just a guess. But I suppose creating 1000 Command structs rather that reusing just one could be a penalty.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.