On Wed, Nov 12, 2014 at 05:52:29AM -0500, Jeff King wrote:

> > However, my personal taste says that reusing the same memory is more
> > elegant than to waste extra memory unnecessarily, so I will go with the
> > child_process_init() solution.
> 
> I do not mind much either way. But I doubt that a single extra struct on
> the stack will break the bank, compared to the fact that we are forking
> and execing a new program. I'd also not be surprised if a smart compiler
> could notice that the variables are used exclusively in non-overlapping
> bits of the code, and just reuse the stack space.

Actually, I take that back. We are passing a pointer to a struct, rather
than by-value, so the compiler cannot know that the sub-function does
not store that pointer in a static variable, and reference it in the
next call. It must use two variables if it cannot see the definition of
run_command.

I still think it's pointless optimization to worry about, and you should
write whichever is the most readable and maintainable.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to