Skip to content

Commit 4cb2b1c

Browse files
committed
Reduce buildBlock overloads with pairwise buildBlock(combining:into:).
This patch replaces `O(2^arity)` overloads of `buildBlock` with `O(arity^2)` overloads of `buildBlock(combining:into:)` with the language feature implemented in swiftlang/swift#40799. This improves library compilation time and fixes an issue where nested captures did not have a flattened type. This also allows us to switch back to native tuples for `Match`, which will be addressed in a follow-up patch.
1 parent 4c252c0 commit 4cb2b1c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/_StringProcessing/RegexDSL/DSLTree.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,11 @@ extension DSLTree.Node {
493493
}
494494
return .concatenation([self, newNode])
495495
}
496+
497+
func appendingAlternationCase(_ newNode: DSLTree.Node) -> DSLTree.Node {
498+
if case .alternation(let components) = self {
499+
return .alternation(components + [newNode])
500+
}
501+
return .alternation([self, newNode])
502+
}
496503
}

0 commit comments

Comments
 (0)