From cd46be7726c22523e0234790e7a02e8ea617e99e Mon Sep 17 00:00:00 2001 From: Nick Condron Date: Thu, 26 Jan 2023 00:19:20 -0500 Subject: [PATCH] Simplify common_symbols by using iterators (#28) --- src/obj/elf.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/obj/elf.rs b/src/obj/elf.rs index 505bfb7..cd81306 100644 --- a/src/obj/elf.rs +++ b/src/obj/elf.rs @@ -126,13 +126,10 @@ fn symbols_by_section(obj_file: &File<'_>, section: &ObjSection) -> Result) -> Result> { - let mut result = Vec::::new(); - for symbol in obj_file.symbols() { - if symbol.is_common() { - result.push(to_obj_symbol(obj_file, &symbol, 0)?); - } - } - Ok(result) + obj_file.symbols() + .filter(Symbol::is_common) + .map(|symbol| to_obj_symbol(obj_file, &symbol, 0)) + .collect::>>() } fn find_section_symbol(