On Sat, Nov 21, 2020 at 07:31:09PM +0100, Martin Ågren wrote: > The previous commit left us with only one user of the one-line wrapper > `color_set()`. We could inline it, but note how we're `xsnprintf()`-ing > all the entries in one array into another array of the same type. We > might as well just `memcpy()` everything into place. > > Signed-off-by: Martin Ågren <martin.agren@xxxxxxxxx> > --- > Cc-ing Peff, who initially introduced this helper. After having inlined > the function into the for loop, it seemed better to just copy the whole > array. Happy to hear arguments against. No, this is way better than the existing code. I introduced it to get away from strcpy(), but this is better still. But... > Come to think of it, I suppose we could copy the whole struct and not > just the color array. Hmmm... Yes, this seems even better. If our goal is just to start our new grep_opt the same as grep_defaults, then a single-line struct copy (whether through assignment or memcpy) is even clearer and more maintainable. -Peff