Thread (19 messages) 19 messages, 4 authors, 2016-06-15

Re: [PATCH 3/3] introduce "format" date-mode

flat view

From: Jeff King <hidden>
Date: 2016-06-15 23:05:36

On Tue, Jun 30, 2015 at 02:13:53PM -0400, Eric Sunshine wrote:
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help