From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12574 invoked by alias); 13 Feb 2020 14:11:54 -0000 Mailing-List: contact dwz-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: dwz-owner@sourceware.org Received: (qmail 12565 invoked by uid 89); 13 Feb 2020 14:11:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-Spam-Status: No, score=-25.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: mx2.suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Date: Wed, 01 Jan 2020 00:00:00 -0000 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com Subject: [committed] Restructure new_size calculation Message-ID: <20200213141135.GA14380@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-SW-Source: 2020-q1/txt/msg00066.txt 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 * 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)