Skip to content

Commit 1f62b62

Browse files
committed
Don't clone directive lists during execution
1 parent 5ce330a commit 1f62b62

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

src/types/base.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,7 @@ fn resolve_selection_set_into<T, CtxT>(
300300
for selection in selection_set {
301301
match selection {
302302
&Selection::Field(Spanning { item: ref f, start: ref start_pos, .. }) => {
303-
if is_excluded(
304-
&match &f.directives {
305-
&Some(ref sel) => Some(sel.iter().cloned().map(|s| s.item).collect()),
306-
&None => None,
307-
},
308-
executor.variables()) {
303+
if is_excluded(&f.directives, executor.variables()) {
309304
continue;
310305
}
311306

@@ -347,12 +342,7 @@ fn resolve_selection_set_into<T, CtxT>(
347342
}
348343
},
349344
&Selection::FragmentSpread(Spanning { item: ref spread, .. }) => {
350-
if is_excluded(
351-
&match &spread.directives {
352-
&Some(ref sel) => Some(sel.iter().cloned().map(|s| s.item).collect()),
353-
&None => None,
354-
},
355-
executor.variables()) {
345+
if is_excluded(&spread.directives, executor.variables()) {
356346
continue;
357347
}
358348

@@ -363,12 +353,7 @@ fn resolve_selection_set_into<T, CtxT>(
363353
instance, &fragment.selection_set[..], executor, result);
364354
},
365355
&Selection::InlineFragment(Spanning { item: ref fragment, start: ref start_pos, .. }) => {
366-
if is_excluded(
367-
&match &fragment.directives {
368-
&Some(ref sel) => Some(sel.iter().cloned().map(|s| s.item).collect()),
369-
&None => None
370-
},
371-
executor.variables()) {
356+
if is_excluded(&fragment.directives, executor.variables()) {
372357
continue;
373358
}
374359

@@ -404,9 +389,9 @@ fn resolve_selection_set_into<T, CtxT>(
404389
}
405390
}
406391

407-
fn is_excluded(directives: &Option<Vec<Directive>>, vars: &HashMap<String, InputValue>) -> bool {
392+
fn is_excluded(directives: &Option<Vec<Spanning<Directive>>>, vars: &HashMap<String, InputValue>) -> bool {
408393
if let Some(ref directives) = *directives {
409-
for directive in directives {
394+
for &Spanning { item: ref directive, .. } in directives {
410395
let condition: bool = directive.arguments.iter()
411396
.flat_map(|m| m.item.get("if"))
412397
.flat_map(|v| v.item.clone().into_const(vars).convert())

0 commit comments

Comments
 (0)