Skip to content

Commit

Permalink
Merge pull request #1389 from sicherha/improvement_lambdas_and_ranges
Browse files Browse the repository at this point in the history
Small improvements: lambdas and ranges
  • Loading branch information
rui314 authored Dec 27, 2024
2 parents 30f6810 + 7d1c970 commit d4db31c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/gdb-index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ static std::vector<Compunit> read_compunits(Context<E> &ctx) {

// Uniquify elements because GCC 11 seems to emit one record for each
// comdat group which results in having a lot of duplicate records.
tbb::parallel_for_each(cus, [&](Compunit &cu) {
tbb::parallel_for_each(cus, [](Compunit &cu) {
sort(cu.nametypes);
remove_duplicates(cu.nametypes);
});
Expand Down
2 changes: 1 addition & 1 deletion src/icf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ static void print_icf_sections(Context<E> &ctx) {
});

tbb::parallel_sort(leaders.begin(), leaders.end(),
[&](InputSection<E> *a, InputSection<E> *b) {
[](InputSection<E> *a, InputSection<E> *b) {
return a->get_priority() < b->get_priority();
});

Expand Down
6 changes: 3 additions & 3 deletions src/input-files.cc
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ void ObjectFile<E>::initialize_symbols(Context<E> &ctx) {
template <typename E>
void ObjectFile<E>::sort_relocations(Context<E> &ctx) {
if constexpr (is_riscv<E> || is_loongarch<E>) {
auto less = [&](const ElfRel<E> &a, const ElfRel<E> &b) {
auto less = [](const ElfRel<E> &a, const ElfRel<E> &b) {
return a.r_offset < b.r_offset;
};

Expand Down Expand Up @@ -1106,7 +1106,7 @@ template <typename E>
void ObjectFile<E>::compute_symtab_size(Context<E> &ctx) {
this->output_sym_indices.resize(this->elf_syms.size(), -1);

auto is_alive = [&](Symbol<E> &sym) -> bool {
auto is_alive = [](Symbol<E> &sym) -> bool {
if (SectionFragment<E> *frag = sym.get_frag())
return frag->is_alive;
if (InputSection<E> *isec = sym.get_input_section())
Expand Down Expand Up @@ -1399,7 +1399,7 @@ std::span<Symbol<E> *> SharedFile<E>::get_symbols_at(Symbol<E> *sym) {
});

auto [begin, end] = std::equal_range(sorted_syms.begin(), sorted_syms.end(),
sym, [&](Symbol<E> *a, Symbol<E> *b) {
sym, [](Symbol<E> *a, Symbol<E> *b) {
return a->esym().st_value < b->esym().st_value;
});

Expand Down
2 changes: 1 addition & 1 deletion src/lto-unix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ std::vector<ObjectFile<E> *> run_lto_plugin(Context<E> &ctx) {
phase = 2;

// Set `referenced_by_regular_obj` bit.
tbb::parallel_for_each(ctx.objs, [&](ObjectFile<E> *file) {
tbb::parallel_for_each(ctx.objs, [](ObjectFile<E> *file) {
if (!file->is_lto_obj) {
for (Symbol<E> *sym : file->get_global_syms()) {
if (sym->file && !sym->file->is_dso &&
Expand Down
2 changes: 1 addition & 1 deletion src/output-chunks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2238,7 +2238,7 @@ void EhFrameSection<E>::construct(Context<E> &ctx) {

// Remove dead FDEs and assign them offsets within their corresponding
// CIE group.
tbb::parallel_for_each(ctx.objs, [&](ObjectFile<E> *file) {
tbb::parallel_for_each(ctx.objs, [](ObjectFile<E> *file) {
std::erase_if(file->fdes, [](FdeRecord<E> &fde) { return !fde.is_alive; });

i64 offset = 0;
Expand Down
12 changes: 6 additions & 6 deletions src/passes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ void sort_init_fini(Context<E> &ctx) {
vec.push_back({isec, get_init_fini_priority(isec)});
}

sort(vec, [&](const Entry &a, const Entry &b) { return a.prio < b.prio; });
sort(vec, [](const Entry &a, const Entry &b) { return a.prio < b.prio; });

for (i64 i = 0; i < vec.size(); i++)
osec->members[i] = vec[i].sect;
Expand Down Expand Up @@ -1208,7 +1208,7 @@ void sort_ctor_dtor(Context<E> &ctx) {
for (InputSection<E> *isec : osec->members)
vec.push_back({isec, get_ctor_dtor_priority(isec)});

sort(vec, [&](const Entry &a, const Entry &b) { return a.prio < b.prio; });
sort(vec, [](const Entry &a, const Entry &b) { return a.prio < b.prio; });

for (i64 i = 0; i < vec.size(); i++)
osec->members[i] = vec[i].sect;
Expand Down Expand Up @@ -1542,7 +1542,7 @@ template <typename E>
void compute_imported_symbol_weakness(Context<E> &ctx) {
Timer t(ctx, "compute_imported_symbol_weakness");

tbb::parallel_for_each(ctx.objs, [&](ObjectFile<E> *file) {
tbb::parallel_for_each(ctx.objs, [](ObjectFile<E> *file) {
for (i64 i = file->first_global; i < file->elf_syms.size(); i++) {
const ElfSym<E> &esym = file->elf_syms[i];
Symbol<E> &sym = *file->symbols[i];
Expand Down Expand Up @@ -1697,7 +1697,7 @@ void sort_dynsyms(Context<E> &ctx) {
// .dynsym.
if (ctx.gnu_hash) {
auto first_exported = std::stable_partition(first_global, syms.end(),
[&](Symbol<E> *sym) {
[](Symbol<E> *sym) {
return !sym->is_exported;
});

Expand Down Expand Up @@ -1939,7 +1939,7 @@ void compute_import_export(Context<E> &ctx) {
// If we are creating an executable, we want to export symbols referenced
// by DSOs unless they are explicitly marked as local by a version script.
if (!ctx.arg.shared) {
tbb::parallel_for_each(ctx.dsos, [&](SharedFile<E> *file) {
tbb::parallel_for_each(ctx.dsos, [](SharedFile<E> *file) {
for (Symbol<E> *sym : file->symbols) {
if (sym->file && !sym->file->is_dso && sym->visibility != STV_HIDDEN &&
sym->ver_idx != VER_NDX_LOCAL) {
Expand Down Expand Up @@ -2299,7 +2299,7 @@ void sort_output_sections_by_order(Context<E> &ctx) {
chunk->sect_order = get_rank(chunk);

// Sort output sections by --section-order
sort(ctx.chunks, [&](Chunk<E> *a, Chunk<E> *b) {
sort(ctx.chunks, [](Chunk<E> *a, Chunk<E> *b) {
return a->sect_order < b->sect_order;
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/relocatable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ template <typename E>
static void r_claim_unresolved_symbols(Context<E> &ctx) {
Timer t(ctx, "r_claim_unresolved_symbols");

tbb::parallel_for_each(ctx.objs, [&](ObjectFile<E> *file) {
tbb::parallel_for_each(ctx.objs, [](ObjectFile<E> *file) {
if (!file->is_alive)
return;

Expand Down
2 changes: 1 addition & 1 deletion src/shrink-sections.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void shrink_sections<E>(Context<E> &ctx) {

std::span<const ElfRel<E>> rels = isec->get_rels(ctx);
auto it = std::lower_bound(rels.begin(), rels.end(), sym->value,
[&](const ElfRel<E> &r, u64 val) {
[](const ElfRel<E> &r, u64 val) {
return r.r_offset < val;
});

Expand Down

0 comments on commit d4db31c

Please sign in to comment.