Skip to content

Commit 0fe4ffb

Browse files
committed
Removed unnecessary IEnumerable materialization
1 parent 5c075a3 commit 0fe4ffb

4 files changed

Lines changed: 8 additions & 22 deletions

File tree

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/PreMergeValidation/Rules/ExternalArgumentDefaultMismatchRule.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ public void Handle(OutputFieldGroupEvent @event, CompositionContext context)
2020
{
2121
var (fieldName, fieldGroup, typeName) = @event;
2222

23-
var externalFields = fieldGroup
24-
.Where(i => i.Field.HasExternalDirective())
25-
.ToImmutableArray();
26-
27-
if (externalFields.Length == 0)
23+
if (!fieldGroup.Any(i => i.Field.HasExternalDirective()))
2824
{
2925
return;
3026
}

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/SourceSchemaMerger.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ private EnumTypeDefinition MergeEnumTypes(ImmutableArray<TypeInfo> typeGroup)
196196
.SelectMany(
197197
i => ((EnumTypeDefinition)i.Type).Values,
198198
(i, v) => new EnumValueInfo(v, (EnumTypeDefinition)i.Type, i.Schema))
199-
.GroupBy(i => i.EnumValue.Name)
200-
.ToImmutableArray();
199+
.GroupBy(i => i.EnumValue.Name);
201200

202201
foreach (var grouping in enumValueGroupByName)
203202
{
@@ -252,8 +251,7 @@ private InputObjectTypeDefinition MergeInputTypes(ImmutableArray<TypeInfo> typeG
252251
(i, f) => new InputFieldInfo(f, (InputObjectTypeDefinition)i.Type, i.Schema))
253252
.GroupBy(i => i.Field.Name)
254253
// Intersection: Field definition count matches type definition count.
255-
.Where(g => g.Count() == typeGroup.Length)
256-
.ToImmutableArray();
254+
.Where(g => g.Count() == typeGroup.Length);
257255

258256
foreach (var grouping in fieldGroupByName)
259257
{
@@ -341,8 +339,7 @@ private InterfaceTypeDefinition MergeInterfaceTypes(ImmutableArray<TypeInfo> typ
341339
.SelectMany(
342340
i => ((InterfaceTypeDefinition)i.Type).Fields,
343341
(i, f) => new OutputFieldInfo(f, (ComplexTypeDefinition)i.Type, i.Schema))
344-
.GroupBy(i => i.Field.Name)
345-
.ToImmutableArray();
342+
.GroupBy(i => i.Field.Name);
346343

347344
foreach (var grouping in fieldGroupByName)
348345
{
@@ -404,8 +401,7 @@ private InterfaceTypeDefinition MergeInterfaceTypes(ImmutableArray<TypeInfo> typ
404401
.SelectMany(
405402
i => ((ObjectTypeDefinition)i.Type).Fields,
406403
(i, f) => new OutputFieldInfo(f, (ComplexTypeDefinition)i.Type, i.Schema))
407-
.GroupBy(i => i.Field.Name)
408-
.ToImmutableArray();
404+
.GroupBy(i => i.Field.Name);
409405

410406
foreach (var grouping in fieldGroupByName)
411407
{
@@ -470,8 +466,7 @@ private InterfaceTypeDefinition MergeInterfaceTypes(ImmutableArray<TypeInfo> typ
470466
.Where(i => !i.Argument.HasRequireDirective())
471467
.GroupBy(i => i.Argument.Name)
472468
// Intersection: Argument definition count matches field definition count.
473-
.Where(g => g.Count() == fieldGroup.Length)
474-
.ToImmutableArray();
469+
.Where(g => g.Count() == fieldGroup.Length);
475470

476471
foreach (var grouping in argumentGroupByName)
477472
{

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/SourceSchemaValidation/Rules/ExternalUnusedRule.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections.Immutable;
21
using HotChocolate.Fusion.Events;
32
using HotChocolate.Fusion.Extensions;
43
using HotChocolate.Skimmed;
@@ -25,8 +24,7 @@ public void Handle(OutputFieldEvent @event, CompositionContext context)
2524
schema.Types
2625
.OfType<ComplexTypeDefinition>()
2726
.SelectMany(t => t.Fields)
28-
.Where(f => f.Type == type)
29-
.ToImmutableArray();
27+
.Where(f => f.Type == type);
3028

3129
var isReferenced =
3230
referencingFields.Any(f => ValidationHelper.ProvidesFieldName(f, field.Name));

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/SourceSchemaValidator.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ private void PublishEntityEvents(
9696
SchemaDefinition schema,
9797
CompositionContext context)
9898
{
99-
var keyDirectives =
100-
entityType.Directives
101-
.Where(d => d.Name == DirectiveNames.Key)
102-
.ToArray();
99+
var keyDirectives = entityType.Directives.Where(d => d.Name == DirectiveNames.Key);
103100

104101
foreach (var keyDirective in keyDirectives)
105102
{

0 commit comments

Comments
 (0)