Skip to content

Commit b54eb25

Browse files
authored
Remove a lot of cloning from ast::ext::SchemaDocumentExtension (#48)
1 parent 6cac0cc commit b54eb25

17 files changed

+428
-411
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ authors = ["Dotan Simha <[email protected]>"]
1212

1313
[dependencies]
1414
graphql-parser = "^0.4.0"
15+
lazy_static = "1.4.0"
1516
serde = { version = "1.0", features = ["derive"] }
1617
serde_json = "1.0"
1718

src/ast/collect_fields.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::static_graphql::{
99
pub fn collect_fields<'a>(
1010
selection_set: &query::SelectionSet,
1111
parent_type: &schema::TypeDefinition,
12-
known_fragments: &HashMap<String, query::FragmentDefinition>,
12+
known_fragments: &HashMap<&str, &query::FragmentDefinition>,
1313
context: &'a OperationVisitorContext<'a>,
1414
) -> HashMap<String, Vec<query::Field>> {
1515
let mut map = HashMap::new();
@@ -36,7 +36,7 @@ fn does_fragment_condition_match<'a>(
3636
if let Some(conditional_type) = context.schema.type_by_name(type_name) {
3737
if conditional_type
3838
.name()
39-
.eq(&current_selection_set_type.name())
39+
.eq(current_selection_set_type.name())
4040
{
4141
return true;
4242
}
@@ -63,7 +63,7 @@ fn does_fragment_condition_match<'a>(
6363
fn collect_fields_inner<'a>(
6464
selection_set: &query::SelectionSet,
6565
parent_type: &schema::TypeDefinition,
66-
known_fragments: &HashMap<String, query::FragmentDefinition>,
66+
known_fragments: &HashMap<&str, &query::FragmentDefinition>,
6767
context: &'a OperationVisitorContext<'a>,
6868
result_arr: &mut HashMap<String, Vec<query::Field>>,
6969
visited_fragments_names: &mut Vec<String>,
@@ -93,7 +93,7 @@ fn collect_fields_inner<'a>(
9393
{
9494
visited_fragments_names.push(f.fragment_name.clone());
9595

96-
if let Some(fragment) = known_fragments.get(&f.fragment_name) {
96+
if let Some(fragment) = known_fragments.get(f.fragment_name.as_str()) {
9797
if does_fragment_condition_match(
9898
&Some(fragment.type_condition.clone()),
9999
&parent_type,

0 commit comments

Comments
 (0)