Re: [PATCH 1/4] lib/sprintf: add scnprintf_append() helper function
From: Andrew Morton
Date: Fri Nov 07 2025 - 19:11:31 EST
On Fri, 7 Nov 2025 09:12:46 +0000 David Laight <david.laight.linux@xxxxxxxxx> wrote:
> > I wonder if we should instead implement a kasprintf() version of this
> > which reallocs each time and then switch all the callers over to that.
>
> That adds the cost of a malloc, and I, like kasprintf() probably ends up
> doing all the work of snprintf twice.
There is no need at all to optimize the performance of scruffy once-off
string pasting functions. For these it's better to optimize for
readability, reliability. maintainability.