Skip to content

Commit b9f004e

Browse files
authored
Merge pull request #32 from Shopify/jb/faster-serialization
Write to a buf before writing to stdout
2 parents 93ce9a0 + 6e363af commit b9f004e

File tree

1 file changed

+3
-2
lines changed
  • shopify_function_macro/src

1 file changed

+3
-2
lines changed

shopify_function_macro/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ pub fn shopify_function(
104104
std::io::Read::read_to_string(&mut #input_stream, &mut string)?;
105105
let input: #input_type = serde_json::from_str(&string)?;
106106
let mut out = #output_stream;
107-
let mut serializer = serde_json::Serializer::new(&mut out);
108-
#name(input)?.serialize(&mut serializer)?;
107+
let result = #name(input)?;
108+
let serialized = serde_json::to_vec(&result)?;
109+
std::io::Write::write_all(&mut out, serialized.as_slice())?;
109110
Ok(())
110111
}
111112
#ast

0 commit comments

Comments
 (0)