Skip to content

Commit 6a4b883

Browse files
committed
Don't clone fragment names in executor
1 parent 96c1ad0 commit 6a4b883

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/executor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub enum FieldPath<'a> {
3535
/// The executor helps drive the query execution in a schema. It keeps track
3636
/// of the current field stack, context, variables, and errors.
3737
pub struct Executor<'a, CtxT> where CtxT: 'a {
38-
fragments: &'a HashMap<String, Fragment>,
38+
fragments: &'a HashMap<&'a str, &'a Fragment>,
3939
variables: &'a HashMap<String, InputValue>,
4040
current_selection_set: Option<Vec<Selection>>,
4141
schema: &'a SchemaType,
@@ -232,7 +232,7 @@ impl<'a, CtxT> Executor<'a, CtxT> {
232232

233233
#[doc(hidden)]
234234
pub fn fragment_by_name(&self, name: &str) -> Option<&'a Fragment> {
235-
self.fragments.get(name)
235+
self.fragments.get(name).map(|f| *f)
236236
}
237237

238238
/// Add an error to the execution engine
@@ -337,7 +337,7 @@ pub fn execute_validated_query<'a, QueryT, MutationT, CtxT>(
337337

338338
{
339339
let executor = Executor {
340-
fragments: &fragments.into_iter().map(|f| (f.item.name.item.clone(), f.item)).collect(),
340+
fragments: &fragments.iter().map(|f| (f.item.name.item.as_str(), &f.item)).collect(),
341341
variables: variables,
342342
current_selection_set: Some(op.item.selection_set),
343343
schema: &root_node.schema,

0 commit comments

Comments
 (0)