Skip to content

Commit e5c632d

Browse files
authored
Merge pull request #363 from Ten0/fix_unnecessary_boxes
Fix unnecessary boxes introduced by 472aad5
2 parents 472aad5 + 03b570a commit e5c632d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

graphql_client_codegen/src/schema.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,13 @@ impl StoredInputType {
400400
}
401401
}
402402

403-
fn contains_type_without_indirection(
404-
&self,
403+
fn contains_type_without_indirection<'a>(
404+
&'a self,
405405
input_id: InputId,
406-
schema: &Schema,
407-
visited_types: &mut HashSet<String>,
406+
schema: &'a Schema,
407+
visited_types: &mut HashSet<&'a str>,
408408
) -> bool {
409-
visited_types.insert(self.name.clone());
409+
visited_types.insert(&self.name);
410410
// The input type is recursive if any of its members contains it, without indirection
411411
self.fields.iter().any(|(_name, field_type)| {
412412
// the field is indirected, so no boxing is needed
@@ -424,8 +424,8 @@ impl StoredInputType {
424424
let input = schema.get_input(field_input_id);
425425

426426
// no need to visit type twice (prevents infinite recursion)
427-
if visited_types.contains(&input.name) {
428-
return true;
427+
if visited_types.contains(&input.name.as_str()) {
428+
return false;
429429
}
430430

431431
// we check if the other input contains this one (without indirection)
@@ -440,7 +440,7 @@ impl StoredInputType {
440440

441441
pub(crate) fn input_is_recursive_without_indirection(input_id: InputId, schema: &Schema) -> bool {
442442
let input = schema.get_input(input_id);
443-
let mut visited_types = HashSet::<String>::new();
443+
let mut visited_types = HashSet::<&str>::new();
444444
input.contains_type_without_indirection(input_id, schema, &mut visited_types)
445445
}
446446
impl std::convert::From<graphql_parser::schema::Document> for Schema {

0 commit comments

Comments
 (0)