Skip to content

Commit

Permalink
Fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
giginet committed Aug 7, 2024
1 parent ca812eb commit f578e3d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Sources/XcodeGenCore/ArrayExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Foundation

public extension Array {
public extension Array where Element: Sendable {

func parallelMap<T>(transform: @Sendable (Element) -> T) -> [T] {
var buffer: [T] = []
DispatchQueue.concurrentPerform(iterations: count) { idx in
buffer[idx] = transform(self[idx])
}
return buffer
var buffer = Array<T?>(repeating: nil, count: count)
DispatchQueue.concurrentPerform(iterations: count) { idx in
buffer[idx] = transform(self[idx])
}
return buffer.map { $0! }
}
}

Expand Down

0 comments on commit f578e3d

Please sign in to comment.