From: Shawn O. Pearce Date: Sat, 26 May 2007 05:24:40 +0000 (-0400) Subject: Micro-optimize prepare_alt_odb X-Git-Tag: v1.5.3-rc0~171^2~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7dc24aa5a62cc5f77e6637674581c837f4bdf78e;p=git.git Micro-optimize prepare_alt_odb Calling getenv() is not that expensive, but its also not free, and its certainly not cheaper than testing to see if alt_odb_tail is not null. Because we are calling prepare_alt_odb() from within find_sha1_file every time we cannot find an object file locally we want to skip out of prepare_alt_odb() as early as possible once we have initialized our alternate list. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- diff --git a/sha1_file.c b/sha1_file.c index 6a5ba6350..a3637d7e5 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -376,11 +376,12 @@ void prepare_alt_odb(void) { const char *alt; + if (alt_odb_tail) + return; + alt = getenv(ALTERNATE_DB_ENVIRONMENT); if (!alt) alt = ""; - if (alt_odb_tail) - return; alt_odb_tail = &alt_odb_list; link_alt_odb_entries(alt, alt + strlen(alt), ':', NULL, 0);