From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id A986E385801A for ; Sat, 27 Mar 2021 19:13:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A986E385801A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B63E9AA55; Sat, 27 Mar 2021 19:13:58 +0000 (UTC) Date: Sat, 27 Mar 2021 20:13:56 +0100 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org Subject: [committed] Minimize struct file_result Message-ID: <20210327191355.GA22285@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Mar 2021 19:14:01 -0000 Hi, Struct file_result contains fields dev, ino and nlink, which are only used during hard link detection. Move these from struct file_result to a new struct hl_stat. Committed to trunk. Thanks, - Tom Minimize struct file_result 2021-03-27 Tom de Vries * dwz.c (struct file_result): Move fields dev, ino and nlink ... (struct hl_stat): ... here. New struct. (detect_hardlinks): Use struct hl_stat. --- dwz.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/dwz.c b/dwz.c index eeae750..40829ac 100644 --- a/dwz.c +++ b/dwz.c @@ -15040,7 +15040,7 @@ clear_p2_field (void) } #endif -/* Helper structure for hardlink discovery. */ +/* Helper structure for file state. */ struct file_result { /* -3: Uninitialized. @@ -15049,9 +15049,6 @@ struct file_result 0: Processed, changed. 1: Processed, unchanged. */ int res; - dev_t dev; - ino_t ino; - nlink_t nlink; size_t hardlink_to; unsigned int die_count; bool skip_multifile; @@ -16296,11 +16293,20 @@ dwz_one_file (const char *file, const char *outfile) return dwz_with_low_mem (file, outfile, &res); } +/* Helper structure for hardlink discovery. */ +struct hl_stat +{ + dev_t dev; + ino_t ino; + nlink_t nlink; +}; + /* Detect which FILES are hardlinks, and mark those in RESA. */ static bool detect_hardlinks (int nr_files, char *files[], struct file_result *resa) { bool found = false; + struct hl_stat hl_stat[nr_files]; int i; /* Try to open all files. */ @@ -16321,9 +16327,9 @@ detect_hardlinks (int nr_files, char *files[], struct file_result *resa) else { res->res = 1; - res->dev = st.st_dev; - res->ino = st.st_ino; - res->nlink = st.st_nlink; + hl_stat[i].dev = st.st_dev; + hl_stat[i].ino = st.st_ino; + hl_stat[i].nlink = st.st_nlink; } close (fd); @@ -16333,14 +16339,14 @@ detect_hardlinks (int nr_files, char *files[], struct file_result *resa) for (i = 0; i < nr_files; i++) { struct file_result *res = &resa[i]; - size_t n; - for (n = 0; &resa[n] != res; n++) + int n; + for (n = 0; n != i; n++) if (resa[n].res >= 0 - && resa[n].nlink > 1 - && resa[n].dev == res->dev - && resa[n].ino == res->ino) + && hl_stat[n].nlink > 1 + && hl_stat[n].dev == hl_stat[i].dev + && hl_stat[n].ino == hl_stat[i].ino) break; - if (&resa[n] == res) + if (n == i) continue; res->res = -2; res->hardlink_to = n;