This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 1/6] Code cleanup: dwarf2read.c:uniquify_cu_indices: Use std::unique
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 12 Jun 2017 17:14:06 +0100
- Subject: [PATCH 1/6] Code cleanup: dwarf2read.c:uniquify_cu_indices: Use std::unique
- Authentication-results: sourceware.org; auth=none
- 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 at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 753FCC0587D7
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 753FCC0587D7
- References: <8efc0742-1014-4fe0-6948-f40a9c5c4975@redhat.com>
gdb/ChangeLog:
2017-06-12 Pedro Alves <palves@redhat.com>
* 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 <palves@redhat.com>
+
+ * dwarf2read.c (uniquify_cu_indices): Use std::unique and
+ std::vector::erase.
+
2017-06-12 Jan Kratochvil <jan.kratochvil@redhat.com>
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 ());
}
}
}
--
2.5.5