We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4cea05a commit 8c151e0Copy full SHA for 8c151e0
Sources/_StringProcessing/Algorithms/Matching/Matches.swift
@@ -349,6 +349,12 @@ extension BidirectionalCollection where SubSequence == Substring {
349
public func matches<Output>(
350
of r: some RegexComponent<Output>
351
) -> [Regex<Output>.Match] {
352
- Array(_matches(of: r))
+ // FIXME: Array init calls count, which double-executes the regex :-(
353
+ // FIXME: just return some Collection<Regex<Output>.Match>
354
+ var result = Array<Regex<Output>.Match>()
355
+ for match in _matches(of: r) {
356
+ result.append(match)
357
+ }
358
+ return result
359
}
360
0 commit comments