Re: [PATCH 3/3] introduce "format" date-mode
- From
Jeff King <peff@peff.net>
- Date
- Jun 30, 2015, 19:22 UTC
- Message-ID
- <20150630192215.GB6845@peff.net>
- In-Reply-To
- <CAPig+cSJXZjrZ=OcV+C6bkCEHQFrw35-cjQ3At_Qo5KrpYxaQA@mail.gmail.com>
On Tue, Jun 30, 2015 at 02:13:53PM -0400, Eric Sunshine wrote:
Show 12 quoted lines
> Sorry, I meant that the interpolation expense of "%s ". A cheaper (but > more verbose) alternative might be: > > size_t n = strlen(fmt); > const char *f = xmalloc(n + 2); > strcpy(f, fmt); > f[n] = ' '; > f[n + 1] = '\0'; > ... > free(f); > > or something similar.
I think you're probably getting into premature optimization here. Using strbuf_vaddf should be within the same order of magnitude of instructions (and I think we should almost never hit this code path anyway, because we'll be reading into a static strbuf generally which will come pre-sized to hold a date).
-Peff