aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-06-06 01:54:34 -0400
committerMike Frysinger <vapier@gentoo.org>2015-06-06 01:54:34 -0400
commit5d20d5da741d6e6665b7c1e4fb6873d22f186222 (patch)
treecf6f35a6a8557ffdd35b9a884cbaa85a4a2a2735
parentqsearch: update cache handling (diff)
downloadportage-utils-5d20d5da741d6e6665b7c1e4fb6873d22f186222.tar.gz
portage-utils-5d20d5da741d6e6665b7c1e4fb6873d22f186222.tar.bz2
portage-utils-5d20d5da741d6e6665b7c1e4fb6873d22f186222.zip
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.
-rw-r--r--main.c24
1 files 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);