Simplify common_symbols by using iterators (#28)

This commit is contained in:
Nick Condron 2023-01-26 00:19:20 -05:00 committed by GitHub
parent 019493f944
commit cd46be7726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 7 deletions

View File

@ -126,13 +126,10 @@ fn symbols_by_section(obj_file: &File<'_>, section: &ObjSection) -> Result<Vec<O
}
fn common_symbols(obj_file: &File<'_>) -> Result<Vec<ObjSymbol>> {
let mut result = Vec::<ObjSymbol>::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::<Result<Vec<ObjSymbol>>>()
}
fn find_section_symbol(