Thread (11 messages) flat view 11 messages, 3 authors, 2018-02-23

Re: [PATCH 3/3] grep: avoid one strdup() per file

From: Jeff King <hidden>
Date: 2018-02-15 22:18:44

On Thu, Feb 15, 2018 at 10:56:15PM +0100, Rasmus Villemoes wrote:
There is only one instance of grep_source_init(GREP_SOURCE_FILE), and in
that case the path and identifier arguments are equal - not just as
strings, but the same pointer is passed. So we can save some time and
memory by reusing the gs->path = xstrdup_or_null(path) we have already
done as gs->identifier, and changing grep_source_clear accordingly
to avoid a double free.
IMHO this special case is not really worth it, unless we can show that
those few bytes saved somehow make a measurable difference in either
peak memory or execution speed.

-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