Skip to content

Commit 6e36207

Browse files
committed
remove cloning during merge
1 parent 7cc4cc4 commit 6e36207

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/merge.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ use indexmap::IndexMap;
33

44
use crate::parser_util::alias_or_name;
55

6-
pub fn merge<'a, 'b, T>(fields: &[Field<'a, T>]) -> Result<Vec<Field<'a, T>>, String>
6+
pub fn merge<'a, 'b, T>(fields: Vec<Field<'a, T>>) -> Result<Vec<Field<'a, T>>, String>
77
where
8-
T: Text<'a> + Eq + AsRef<str> + Clone,
8+
T: Text<'a> + Eq + AsRef<str>,
99
{
1010
let mut merged: IndexMap<String, Field<'a, T>> = IndexMap::new();
1111

1212
for current_field in fields {
13-
let response_key = alias_or_name(current_field);
13+
let response_key = alias_or_name(&current_field);
1414
match merged.get_mut(&response_key) {
1515
Some(existing_field) => {
16-
if can_merge(current_field, existing_field)? {
16+
if can_merge(&current_field, existing_field)? {
1717
existing_field
1818
.selection_set
1919
.items
20-
.extend(current_field.selection_set.items.iter().cloned());
20+
.extend(current_field.selection_set.items);
2121
}
2222
}
2323
None => {
24-
merged.insert(response_key, (*current_field).clone());
24+
merged.insert(response_key, current_field);
2525
}
2626
}
2727
}

src/parser_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ where
3232
Err(err) => return Err(err),
3333
}
3434
}
35-
let selections = merge(&selections)?;
35+
let selections = merge(selections)?;
3636
Ok(selections)
3737
}
3838

0 commit comments

Comments
 (0)