Skip to content

Commit cd46be7

Browse files
authored
Simplify common_symbols by using iterators (#28)
1 parent 019493f commit cd46be7

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/obj/elf.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,10 @@ fn symbols_by_section(obj_file: &File<'_>, section: &ObjSection) -> Result<Vec<O
126126
}
127127

128128
fn common_symbols(obj_file: &File<'_>) -> Result<Vec<ObjSymbol>> {
129-
let mut result = Vec::<ObjSymbol>::new();
130-
for symbol in obj_file.symbols() {
131-
if symbol.is_common() {
132-
result.push(to_obj_symbol(obj_file, &symbol, 0)?);
133-
}
134-
}
135-
Ok(result)
129+
obj_file.symbols()
130+
.filter(Symbol::is_common)
131+
.map(|symbol| to_obj_symbol(obj_file, &symbol, 0))
132+
.collect::<Result<Vec<ObjSymbol>>>()
136133
}
137134

138135
fn find_section_symbol(

0 commit comments

Comments
 (0)