diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index e7157b365edba541782aa46370986d9ccb11c977..aec1605b3757bb49371a9c35154c2a2452f5a3a1 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -11,6 +11,12 @@ # meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"} # author = "rcoh" +[[smithy-rs]] +message = "Avoid intermediate vec allocations in AggregatedBytes::to_vec." +author = "yotamofek" +references = ["smithy-rs#2786"] +meta = { "breaking" = false, "tada" = false, "bug" = false } + [[smithy-rs]] message = "Fix bug in AWS JSON 1.x routers where, if a service had more than 14 operations, the router was created without the route for the 15th operation." author = "thor-bjorgvinsson" diff --git a/rust-runtime/aws-smithy-http/src/byte_stream.rs b/rust-runtime/aws-smithy-http/src/byte_stream.rs index fcd697c7b4fc2fc1f8633bb535c1d72c2cf6d319..e067018a9db01b3a7a5bf747c1b82b1b84fc7358 100644 --- a/rust-runtime/aws-smithy-http/src/byte_stream.rs +++ b/rust-runtime/aws-smithy-http/src/byte_stream.rs @@ -484,11 +484,7 @@ impl AggregatedBytes { /// Convert this buffer into a `Vec` pub fn to_vec(self) -> Vec { - self.0 - .into_inner() - .into_iter() - .flat_map(|b| b.to_vec()) - .collect() + self.0.into_inner().into_iter().flatten().collect() } }