From 2f78d2eb94484c787d78ba100024359f43b18fc4 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 30 May 2022 13:04:37 +0800 Subject: [PATCH] [Mach-O] Parallelize a part of merge_cstring_sections() --- macho/main.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/macho/main.cc b/macho/main.cc index 8ffe3946..526813ff 100644 --- a/macho/main.cc +++ b/macho/main.cc @@ -264,12 +264,13 @@ static void merge_cstring_sections(Context &ctx) { } } - for (ObjectFile *file : ctx.objs) + tbb::parallel_for_each(ctx.objs, [&](ObjectFile *file) { for (std::unique_ptr> &isec : file->sections) if (isec) for (Relocation &r : isec->rels) if (r.subsec && r.subsec->is_coalesced) r.subsec = r.subsec->replacer; + }); auto replace = [&](InputFile *file) { for (Symbol *sym : file->syms) @@ -277,16 +278,14 @@ static void merge_cstring_sections(Context &ctx) { sym->subsec = sym->subsec->replacer; }; - for (InputFile *file : ctx.objs) - replace(file); - for (InputFile *file : ctx.dylibs) - replace(file); + tbb::parallel_for_each(ctx.objs, replace); + tbb::parallel_for_each(ctx.dylibs, replace); - for (ObjectFile *file : ctx.objs) { + tbb::parallel_for_each(ctx.objs, [&](ObjectFile *file) { std::erase_if(file->subsections, [](Subsection *subsec) { return subsec->is_coalesced; }); - } + }); } template