From 2bcdae33437988fab50f10b74f83f7a9dae5f608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Meier?= Date: Sat, 28 Oct 2023 22:52:14 +0200 Subject: [PATCH 1/2] Avoid an unecessary clone in `LookAheadMethods::children` --- juniper/src/executor/look_ahead.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/juniper/src/executor/look_ahead.rs b/juniper/src/executor/look_ahead.rs index 9a4ab6401..717e157a6 100644 --- a/juniper/src/executor/look_ahead.rs +++ b/juniper/src/executor/look_ahead.rs @@ -364,7 +364,9 @@ pub trait LookAheadMethods<'sel, S> { fn child_names(&self) -> Vec<&'sel str>; /// Get an iterator over the children for the current selection - fn children(&self) -> Vec<&Self>; + fn children(&self) -> &[Self] + where + Self: Sized; /// Get the parent type in case there is any for this selection fn applies_for(&self) -> Option<&str>; @@ -395,8 +397,8 @@ impl<'a, S> LookAheadMethods<'a, S> for ConcreteLookAheadSelection<'a, S> { !self.children.is_empty() } - fn children(&self) -> Vec<&Self> { - self.children.iter().collect() + fn children(&self) -> &[Self] { + &self.children } fn applies_for(&self) -> Option<&str> { @@ -432,8 +434,8 @@ impl<'a, S> LookAheadMethods<'a, S> for LookAheadSelection<'a, S> { !self.children.is_empty() } - fn children(&self) -> Vec<&Self> { - self.children.iter().collect() + fn children(&self) -> &[Self] { + &self.children } fn applies_for(&self) -> Option<&str> { From 6de3577953ab6d4f4a01f836bf83029f98a484cc Mon Sep 17 00:00:00 2001 From: tyranron Date: Thu, 2 Nov 2023 15:15:33 +0200 Subject: [PATCH 2/2] Mention in CHANGELOG --- juniper/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/juniper/CHANGELOG.md b/juniper/CHANGELOG.md index c68fdc6ac..e21ee3a45 100644 --- a/juniper/CHANGELOG.md +++ b/juniper/CHANGELOG.md @@ -52,6 +52,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi - Removed `scalar-naivetime` [Cargo feature]. - Removed lifetime parameter from `ParseError`, `GraphlQLError`, `GraphQLBatchRequest` and `GraphQLRequest`. ([#1081], [#528]) - Upgraded [GraphiQL] to 3.0.8 version (requires new [`graphql-transport-ws` GraphQL over WebSocket Protocol] integration on server, see `juniper_warp/examples/subscription.rs`). ([#1188], [#1193], [#1203]) +- Made `LookAheadMethods::children()` method to return slice instead of `Vec`. ([#1200]) ### Added @@ -128,6 +129,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi [#1190]: /../../pull/1190 [#1193]: /../../pull/1193 [#1199]: /../../pull/1199 +[#1200]: /../../pull/1200 [#1203]: /../../pull/1203 [ba1ed85b]: /../../commit/ba1ed85b3c3dd77fbae7baf6bc4e693321a94083 [CVE-2022-31173]: /../../security/advisories/GHSA-4rx6-g5vg-5f3j