From 45a4fb1a700abeb4b3d8315b312ab31eee8efe72 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Tue, 17 Feb 2015 10:43:20 -0500 Subject: [PATCH] Use std::upper_bound to simplify code a bit. With std::upper_bound we don't have to check p->input_offset > input_offset. --- gold/ChangeLog | 4 ++++ gold/merge.cc | 13 +++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index f83c6524c8a..67efa5855d5 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,7 @@ +2015-02-17 Rafael Ávila de Espíndola + + * merge.cc (get_output_offset): Use upper_bound instead of lower_bound. + 2015-02-09 Mark Wielaard * gdb-index.cc (Gdb_index_info_reader::visit_top_die): Recognize diff --git a/gold/merge.cc b/gold/merge.cc index f547388e308..bf004818119 100644 --- a/gold/merge.cc +++ b/gold/merge.cc @@ -162,15 +162,12 @@ Object_merge_map::get_output_offset(const Merge_map* merge_map, Input_merge_entry entry; entry.input_offset = input_offset; std::vector::const_iterator p = - std::lower_bound(map->entries.begin(), map->entries.end(), + std::upper_bound(map->entries.begin(), map->entries.end(), entry, Input_merge_compare()); - if (p == map->entries.end() || p->input_offset > input_offset) - { - if (p == map->entries.begin()) - return false; - --p; - gold_assert(p->input_offset <= input_offset); - } + if (p == map->entries.begin()) + return false; + --p; + gold_assert(p->input_offset <= input_offset); if (input_offset - p->input_offset >= static_cast(p->length)) -- 2.30.2