Fix build error

And slightly improve efficiency by exiting early from an iteration
This commit is contained in:
Brian Carroll 2021-11-04 22:18:10 +00:00
parent 09f2ce327c
commit c5d99433f7
2 changed files with 2 additions and 5 deletions

View file

@ -8,6 +8,4 @@ pub use code_builder::{
Align, BlockType, CodeBuilder, LocalId, ValueType, VirtualMachineSymbolState, Align, BlockType, CodeBuilder, LocalId, ValueType, VirtualMachineSymbolState,
}; };
pub use linking::{LinkingSubSection, SymInfo}; pub use linking::{LinkingSubSection, SymInfo};
pub use sections::{ pub use sections::{ConstExpr, Export, ExportType, Global, GlobalType, Signature, WasmModule};
Export, ExportType, Global, ConstExpr, GlobalType, Signature, WasmModule,
};

View file

@ -516,8 +516,7 @@ impl<'a> DataSection<'a> {
impl Serialize for DataSection<'_> { impl Serialize for DataSection<'_> {
fn serialize<T: SerialBuffer>(&self, buffer: &mut T) { fn serialize<T: SerialBuffer>(&self, buffer: &mut T) {
let total_payload_size = self.segments.iter().map(|seg| seg.init.len()).sum(); if self.segments.iter().any(|seg| !seg.init.is_empty()) {
if total_payload_size > 0 {
serialize_vector_section(buffer, SectionId::Data, &self.segments); serialize_vector_section(buffer, SectionId::Data, &self.segments);
} }
} }