From patchwork Mon Jun 12 16:14:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 20955 Received: (qmail 87450 invoked by alias); 12 Jun 2017 16:14:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 86426 invoked by uid 89); 12 Jun 2017 16:14:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1685 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Jun 2017 16:14:09 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 753FCC0587D7 for ; Mon, 12 Jun 2017 16:14:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 753FCC0587D7 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 753FCC0587D7 Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC30E82F86 for ; Mon, 12 Jun 2017 16:14:11 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 1/6] Code cleanup: dwarf2read.c:uniquify_cu_indices: Use std::unique Date: Mon, 12 Jun 2017 17:14:06 +0100 Message-Id: <1497284051-13795-1-git-send-email-palves@redhat.com> In-Reply-To: <8efc0742-1014-4fe0-6948-f40a9c5c4975@redhat.com> References: <8efc0742-1014-4fe0-6948-f40a9c5c4975@redhat.com> gdb/ChangeLog: 2017-06-12 Pedro Alves * dwarf2read.c (uniquify_cu_indices): Use std::unique and std::vector::erase. --- gdb/ChangeLog | 5 +++++ gdb/dwarf2read.c | 21 ++++----------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 037fa0c..316e03a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2017-06-12 Pedro Alves + + * dwarf2read.c (uniquify_cu_indices): Use std::unique and + std::vector::erase. + 2017-06-12 Jan Kratochvil Code cleanup: C++ify .gdb_index producer. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index ef21092..0c9e275 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -23370,23 +23370,10 @@ uniquify_cu_indices (struct mapped_symtab *symtab) { if (entry && !entry->cu_indices.empty ()) { - unsigned int next_to_insert, next_to_check; - offset_type last_value; - - std::sort (entry->cu_indices.begin (), entry->cu_indices.end ()); - - last_value = entry->cu_indices[0]; - next_to_insert = 1; - for (next_to_check = 1; - next_to_check < entry->cu_indices.size (); - ++next_to_check) - if (entry->cu_indices[next_to_check] != last_value) - { - last_value = entry->cu_indices[next_to_check]; - entry->cu_indices[next_to_insert] = last_value; - ++next_to_insert; - } - entry->cu_indices.resize (next_to_insert); + auto &cu_indices = entry->cu_indices; + std::sort (cu_indices.begin (), cu_indices.end ()); + auto from = std::unique (cu_indices.begin (), cu_indices.end ()); + cu_indices.erase (from, cu_indices.end ()); } } }