This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch][gold] Use std::upper_bound to simplify code a bit
- From: Rafael EspÃndola <rafael dot espindola at gmail dot com>
- To: Binutils <binutils at sourceware dot org>
- Cc: Cary Coutant <ccoutant at google dot com>
- Date: Fri, 6 Feb 2015 11:32:35 -0500
- Subject: [patch][gold] Use std::upper_bound to simplify code a bit
- Authentication-results: sourceware.org; auth=none
With std::upper_bound we don't have to check p->input_offset > input_offset.
Cheers,
Rafael
diff --git a/gold/merge.cc b/gold/merge.cc
index f547388..bf00481 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<Input_merge_entry>::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<section_offset_type>(p->length))