From 547a4f0ba31d40543c88b7a67ff6ebfd015b3c0e Mon Sep 17 00:00:00 2001 From: Anthony Miller Date: Fri, 22 Mar 2024 11:10:39 -0700 Subject: [PATCH] Remove redundant iteration in EntitySelectionTree merging algorithm (apollographql/apollo-ios-dev#308) --- .../Sources/IR/IR+EntitySelectionTree.swift | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/apollo-ios-codegen/Sources/IR/IR+EntitySelectionTree.swift b/apollo-ios-codegen/Sources/IR/IR+EntitySelectionTree.swift index fa8d9636d..8b37a798c 100644 --- a/apollo-ios-codegen/Sources/IR/IR+EntitySelectionTree.swift +++ b/apollo-ios-codegen/Sources/IR/IR+EntitySelectionTree.swift @@ -224,23 +224,6 @@ class EntitySelectionTree { targetSelections.mergeIn(scopeSelections, from: source) } - if let conditionalScopes = scopeConditions { - for (condition, node) in conditionalScopes { - guard !node.scope.isDeferred else { continue } - - if scopePathNode.value.matches(condition) { - node.mergeSelections( - matchingScopePath: scopePathNode, - into: targetSelections, - transformingSelections: transformingSelections - ) - - } else { - targetSelections.addMergedInlineFragment(with: condition) - } - } - } - case .none: break } @@ -254,6 +237,8 @@ class EntitySelectionTree { into: targetSelections, transformingSelections: transformingSelections ) + } else if case .selections = child { + targetSelections.addMergedInlineFragment(with: condition) } } }