{"thread":{"id":"8321","subject":"[PATCH 2/3] Micro-optimize prepare_alt_odb","startedAt":"2007-05-26T05:24:40Z","lastAt":"2007-05-26T05:24:40Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"43325","messageId":"20070526052440.GB11957@spearce.org","threadId":"8321","inReplyTo":null,"subject":"[PATCH 2/3] Micro-optimize prepare_alt_odb","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-05-26T05:24:40Z","receivedAt":"2007-05-26T05:24:40Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Calling getenv() is not that expensive, but its also not free,\nand its certainly not cheaper than testing to see if alt_odb_tail\nis not null.\n\nBecause we are calling prepare_alt_odb() from within find_sha1_file\nevery time we cannot find an object file locally we want to skip out\nof prepare_alt_odb() as early as possible once we have initialized\nour alternate list.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n sha1_file.c |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 6a5ba63..a3637d7 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -376,11 +376,12 @@ void prepare_alt_odb(void)\n {\n \tconst char *alt;\n \n+\tif (alt_odb_tail)\n+\t\treturn;\n+\n \talt = getenv(ALTERNATE_DB_ENVIRONMENT);\n \tif (!alt) alt = \"\";\n \n-\tif (alt_odb_tail)\n-\t\treturn;\n \talt_odb_tail = &alt_odb_list;\n \tlink_alt_odb_entries(alt, alt + strlen(alt), ':', NULL, 0);\n \n-- \n1.5.2.789.g8ee1\n"}]}