From d7e98d955a0109a4645804f9efe33dac51adf738 Mon Sep 17 00:00:00 2001 From: Magnus Hallin Date: Wed, 28 Dec 2016 11:51:37 +0100 Subject: [PATCH] Don't clone field names when recursing down in selection sets --- src/executor.rs | 6 +++--- src/types/base.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/executor.rs b/src/executor.rs index be5f49f8..5fd307eb 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -27,7 +27,7 @@ pub struct Registry { #[derive(Clone)] pub enum FieldPath<'a> { Root(SourcePosition), - Field(String, SourcePosition, &'a FieldPath<'a>), + Field(&'a str, SourcePosition, &'a FieldPath<'a>), } /// Query execution engine @@ -187,7 +187,7 @@ impl<'a, CtxT> Executor<'a, CtxT> { #[doc(hidden)] pub fn sub_executor( &self, - field_name: Option, + field_name: Option<&'a str>, location: SourcePosition, selection_set: Option<&'a [Selection]>, ) @@ -251,7 +251,7 @@ impl<'a> FieldPath<'a> { FieldPath::Root(_) => (), FieldPath::Field(ref name, _, ref parent) => { parent.construct_path(acc); - acc.push(name.clone()); + acc.push((*name).to_owned()); } } } diff --git a/src/types/base.rs b/src/types/base.rs index 92cff735..2f3748b6 100644 --- a/src/types/base.rs +++ b/src/types/base.rs @@ -325,7 +325,7 @@ fn resolve_selection_set_into( let exec_vars = executor.variables(); let mut sub_exec = executor.sub_executor( - Some(response_name.clone()), + Some(response_name), start_pos.clone(), f.selection_set.as_ref().map(|v| &v[..]));