On Thu Apr 27 18:18:01 2023 +0000, Francisco Casas wrote:
I split prepend_input_copy() in two functions: prepend_input_copy() and prepend_input_copy_recurse(). Same for append_output_copy().
Yeah, I expressed myself terribly. The point is not really about recursion (which, as you say, is inevitable) as about the control flow structure, which I find a bit hard to scan. In general I don't really like stuff like: ``` int f(...) { if (condition) { lots_of_code(); return ...; }
lots_of_other_code(); return ...; } ```
This is fine when `lots_of_code()` is actually `a_bit_of_code()`, possibly some cleanup or simple case. Then it's clear that the function has a main linear flow with little branches when needed. If instead the function has two main cases, then they should marked more clearly; even better if one of them can be sent to another helper. With the current code it's pretty clear that `prepend_input_copy_recurse()` recurses a few times and then calls `prepend_input_copy()`, and nothign fancier than that.