public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [committed] Restructure new_size calculation
@ 2020-01-01  0:00 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2020-01-01  0:00 UTC (permalink / raw)
  To: dwz, jakub

Hi,

Restructure the calculation of new_size in partition_dups_1, by introducing
variables for various quantities.

Committed to trunk.

Thanks,
- Tom

Restructure new_size calculation

2020-02-11  Tom de Vries  <tdevries@suse.de>

	* dwz.c (partition_dups_1): Restructure the calculation of new_size.

---
 dwz.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/dwz.c b/dwz.c
index 05dfe05..35d3072 100644
--- a/dwz.c
+++ b/dwz.c
@@ -6893,16 +6893,25 @@ partition_dups_1 (dw_die_ref *arr, size_t vec_size,
       orig_size = size * cnt;
       /* Estimated size of CU header and DW_TAG_partial_unit
 	 with DW_AT_stmt_list and DW_AT_comp_dir attributes
-	 21 (also child end byte), plus in each CU referencing it
-	 DW_TAG_imported_unit with DW_AT_import attribute
-	 (5 or 9 bytes (the latter for DWARF2 and ptr_size 8)).
-	 For DW_TAG_namespace or DW_TAG_module needed as
+	 21 (also child end byte).  */
+      size_t pu_size = 21;
+      /* DW_TAG_imported_unit with DW_AT_import attribute
+	 (5 or 9 bytes (the latter for DWARF2 and ptr_size 8)).  */
+      size_t import_size
+	= (die_cu (arr[i])->cu_version == 2 ? 1 + ptr_size : 5);
+      /* For DW_TAG_namespace or DW_TAG_module needed as
 	 parents of the DIEs conservatively assume 10 bytes
 	 for the abbrev index, DW_AT_name attribute and
 	 DW_AT_sibling attribute and child end.  */
-      new_size = size + 21
-		 + (die_cu (arr[i])->cu_version == 2
-		    ? 1 + ptr_size : 5) * cnt + 10 * namespaces;
+      size_t namespace_size = 10;
+      new_size = (/* Size of DIEs.  */
+		  size
+		  /* Size of PU.  */
+		  + pu_size
+		  /* Size of imports.  */
+		  + import_size * cnt
+		  /* Size of namespace DIEs.  */
+		  + namespace_size * namespaces);
       if (!second_phase)
 	force = ignore_size || orig_size > new_size;
       if (force)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-13 14:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-01  0:00 [committed] Restructure new_size calculation Tom de Vries

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).