diff --git a/compiler/gen_wasm/src/wasm_module/mod.rs b/compiler/gen_wasm/src/wasm_module/mod.rs index 783942b2ff..b925bfafd7 100644 --- a/compiler/gen_wasm/src/wasm_module/mod.rs +++ b/compiler/gen_wasm/src/wasm_module/mod.rs @@ -8,6 +8,4 @@ pub use code_builder::{ Align, BlockType, CodeBuilder, LocalId, ValueType, VirtualMachineSymbolState, }; pub use linking::{LinkingSubSection, SymInfo}; -pub use sections::{ - Export, ExportType, Global, ConstExpr, GlobalType, Signature, WasmModule, -}; +pub use sections::{ConstExpr, Export, ExportType, Global, GlobalType, Signature, WasmModule}; diff --git a/compiler/gen_wasm/src/wasm_module/sections.rs b/compiler/gen_wasm/src/wasm_module/sections.rs index e61e7026d1..ba35d70ba2 100644 --- a/compiler/gen_wasm/src/wasm_module/sections.rs +++ b/compiler/gen_wasm/src/wasm_module/sections.rs @@ -516,8 +516,7 @@ impl<'a> DataSection<'a> { impl Serialize for DataSection<'_> { fn serialize(&self, buffer: &mut T) { - let total_payload_size = self.segments.iter().map(|seg| seg.init.len()).sum(); - if total_payload_size > 0 { + if self.segments.iter().any(|seg| !seg.init.is_empty()) { serialize_vector_section(buffer, SectionId::Data, &self.segments); } }