From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 7EE71138CD3 for ; Sat, 6 Jun 2015 06:20:16 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F0F08E080A; Sat, 6 Jun 2015 06:20:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 94053E080A for ; Sat, 6 Jun 2015 06:20:14 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D07BF340C36 for ; Sat, 6 Jun 2015 06:20:12 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 83A0FA2D for ; Sat, 6 Jun 2015 06:20:11 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1433570074.5d20d5da741d6e6665b7c1e4fb6873d22f186222.vapier@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: main.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 5d20d5da741d6e6665b7c1e4fb6873d22f186222 X-VCS-Branch: master Date: Sat, 6 Jun 2015 06:20:11 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d635cd22-d0e6-47be-8f3f-f302cc1b60f1 X-Archives-Hash: 02c53916f5132070360c26e34acf5be0 commit: 5d20d5da741d6e6665b7c1e4fb6873d22f186222 Author: Mike Frysinger gentoo org> AuthorDate: Sat Jun 6 05:54:34 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sat Jun 6 05:54:34 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5d20d5da cache: optimize the common case slightly Do the cache sanity check immediately on the assumption that it will be sane the majority of the time. No point in opening the portdir and such just to close it immediately. main.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/main.c b/main.c index df1e309..66b3b30 100644 --- a/main.c +++ b/main.c @@ -915,6 +915,19 @@ initialize_flat(int cache_type, bool force) int frac, secs, count; FILE *fp; + xasprintf(&cache_file, "%s/dep/%s/%s", portedb, portdir, + (cache_type == CACHE_EBUILD ? ".ebuild.x" : ".metadata.x")); + + /* If we aren't forcing a regen, make sure the file is somewhat sane. */ + if (!force) { + if (stat(cache_file, &st) != -1) + if (st.st_size) + return cache_file; + } + + if (!quiet) + warn("Updating ebuild %scache ... ", cache_type == CACHE_EBUILD ? "" : "meta"); + count = frac = secs = 0; int portdir_fd, subdir_fd; @@ -933,17 +946,6 @@ initialize_flat(int cache_type, bool force) portcachedir_type = CACHE_METADATA_MD5; } else subdir_fd = portdir_fd; - xasprintf(&cache_file, "%s/dep/%s/%s", portedb, portdir, - (cache_type == CACHE_EBUILD ? ".ebuild.x" : ".metadata.x")); - - /* If we aren't forcing a regen, make sure the file is somewhat sane. */ - if (!force) { - if (stat(cache_file, &st) != -1) - if (st.st_size) - goto ret; - } - if (!quiet) - warn("Updating ebuild %scache ... ", cache_type == CACHE_EBUILD ? "" : "meta"); if ((fp = fopen(cache_file, "we")) == NULL) { warnfp("opening cache failed: %s", cache_file);