public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com
Subject: [committed] Factor out partition_found_dups and sort_dups
Date: Tue, 01 Jan 2019 00:00:00 -0000	[thread overview]
Message-ID: <20191209114728.GA20189@delia> (raw)

Hi,

Factor out new functions partition_found_dups and sort_dups out of
partition_find_dups.

Committed to trunk.

Thanks,
- Tom

Factor out partition_found_dups and sort_dups

2019-12-07  Tom de Vries  <tdevries@suse.de>

	* dwz.c (partition_found_dups, sort_dups): New functions, factored
	out of ...
	(partition_find_dups): ... here.

---
 dwz.c | 62 +++++++++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 39 insertions(+), 23 deletions(-)

diff --git a/dwz.c b/dwz.c
index 1ef65e1..1a1186d 100644
--- a/dwz.c
+++ b/dwz.c
@@ -5970,6 +5970,42 @@ partition_cmp (const void *p, const void *q)
   return 0;
 }
 
+/* Add duplicate chain for DIE to VEC.  */
+static void
+partition_found_dups (dw_die_ref die, struct obstack *vec)
+{
+  obstack_ptr_grow (vec, die);
+  if (unlikely (verify_dups_p))
+    verify_dups (die, true);
+  if (dump_dups)
+    {
+      fprintf (stderr, "duplicate chain:\n");
+      {
+	dw_die_ref d;
+	for (d = die; d; d = d->die_nextdup)
+	  dump_die (d);
+      }
+    }
+}
+
+/* Sort duplication chain for HEAD, assuming the chain was formed by
+   die_eq.  */
+static void
+sort_dups (dw_die_ref head)
+{
+  dw_die_ref prev = NULL, die, next;
+  /* Sort the die_nextdup list by increasing die_cu ()->cu_chunk.
+     When it is originally added, child has the lowest
+     cu_offset, then the DIEs are sorted in the linked list
+     from highest cu_offset down to lowest or second lowest.  */
+  for (die = head->die_nextdup; die; prev = die, die = next)
+    {
+      next = die->die_nextdup;
+      die->die_nextdup = prev;
+    }
+  head->die_nextdup = prev;
+}
+
 /* Search for duplicate removal reference DIE candidates
    in tree rooted by PARENT.  */
 static void
@@ -5982,7 +6018,7 @@ partition_find_dups (struct obstack *vec, dw_die_ref parent)
 	  && child->die_dup == NULL
 	  && child->die_offset != -1U)
 	{
-	  dw_die_ref prev = NULL, die, next;
+	  dw_die_ref die;
 
 	  if (unlikely (op_multifile))
 	    {
@@ -5996,28 +6032,8 @@ partition_find_dups (struct obstack *vec, dw_die_ref parent)
 	      if (die == NULL)
 		continue;
 	    }
-	  /* Sort the die_nextdup list by increasing die_cu ()->cu_chunk.
-	     When it is originally added, child has the lowest
-	     cu_offset, then the DIEs are sorted in the linked list
-	     from highest cu_offset down to lowest or second lowest.  */
-	  for (die = child->die_nextdup; die; prev = die, die = next)
-	    {
-	      next = die->die_nextdup;
-	      die->die_nextdup = prev;
-	    }
-	  child->die_nextdup = prev;
-	  obstack_ptr_grow (vec, child);
-	  if (unlikely (verify_dups_p))
-	    verify_dups (child, true);
-	  if (dump_dups)
-	    {
-	      fprintf (stderr, "duplicate chain:\n");
-	      {
-		dw_die_ref d;
-		for (d = child; d; d = d->die_nextdup)
-		  dump_die (d);
-	      }
-	    }
+	  sort_dups (child);
+	  partition_found_dups (child, vec);
 	}
       else if (child->die_named_namespace)
 	partition_find_dups (vec, child);

                 reply	other threads:[~2019-12-09 11:47 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=20191209114728.GA20189@delia \
    --to=tdevries@suse.de \
    --cc=dwz@sourceware.org \
    --cc=jakub@redhat.com \
    /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).