From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Stefan Beller" <sbeller@google.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
git <git@vger.kernel.org>
Subject: Re: [PATCH 0/6] getenv() timing fixes
Date: Tue, 15 Jan 2019 12:49:48 -0800 [thread overview]
Message-ID: <xmqqef9dr6hf.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190115194726.GA5818@sigill.intra.peff.net> (Jeff King's message of "Tue, 15 Jan 2019 14:47:26 -0500")
Jeff King <peff@peff.net> writes:
> So actually, that's pretty easy to do without writing much code at all.
> Something like:
>
> #define xgetenv(name) strintern(getenv(name))
>
> It means we're effectively storing the environment twice in the worst
> case, but that's probably not a big deal. Unless we have a loop which
> does repeated setenv()/getenv() calls, the strintern hashmap can't grow
> without bound.
Makes sense.
hashmap.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hashmap.h b/hashmap.h
index d375d9cce7..cff77f9890 100644
--- a/hashmap.h
+++ b/hashmap.h
@@ -432,6 +432,8 @@ static inline void hashmap_enable_item_counting(struct hashmap *map)
extern const void *memintern(const void *data, size_t len);
static inline const char *strintern(const char *string)
{
+ if (!string)
+ return string;
return memintern(string, strlen(string));
}
next prev parent reply other threads:[~2019-01-15 20:49 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-11 22:14 [PATCH 0/6] getenv() timing fixes Jeff King
2019-01-11 22:15 ` [PATCH 1/6] get_super_prefix(): copy getenv() result Jeff King
2019-01-12 3:02 ` Junio C Hamano
2019-01-11 22:15 ` [PATCH 2/6] commit: copy saved " Jeff King
2019-01-12 3:07 ` Junio C Hamano
2019-01-12 10:26 ` Jeff King
2019-01-15 14:05 ` Johannes Schindelin
2019-01-15 19:17 ` Jeff King
2019-01-15 19:25 ` Stefan Beller
2019-01-15 19:32 ` Jeff King
2019-01-16 14:06 ` Johannes Schindelin
2019-01-11 22:15 ` [PATCH 3/6] config: make a copy of $GIT_CONFIG string Jeff King
2019-01-11 22:16 ` [PATCH 4/6] init: make a copy of $GIT_DIR string Jeff King
2019-01-12 3:08 ` Junio C Hamano
2019-01-11 22:16 ` [PATCH 5/6] merge-recursive: copy $GITHEAD strings Jeff King
2019-01-12 3:10 ` Junio C Hamano
2019-01-11 22:17 ` [PATCH 6/6] builtin_diff(): read $GIT_DIFF_OPTS closer to use Jeff King
2019-01-12 11:31 ` [PATCH 0/6] getenv() timing fixes Ævar Arnfjörð Bjarmason
2019-01-12 18:51 ` Stefan Beller
2019-01-15 19:13 ` Jeff King
2019-01-15 19:32 ` Junio C Hamano
2019-01-15 19:38 ` Stefan Beller
2019-01-15 19:41 ` Jeff King
2019-01-15 19:47 ` Jeff King
2019-01-15 20:49 ` Junio C Hamano [this message]
2019-01-15 19:12 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqef9dr6hf.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).