From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org
Subject: [committed] Minimize struct file_result
Date: Sat, 27 Mar 2021 20:13:56 +0100 [thread overview]
Message-ID: <20210327191355.GA22285@delia> (raw)
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 <tdevries@suse.de>
* 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;
reply other threads:[~2021-03-27 19:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210327191355.GA22285@delia \
--to=tdevries@suse.de \
--cc=dwz@sourceware.org \
--cc=jakub@redhat.com \
--cc=mark@klomp.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).