|
|
|
|
|
by KolmogorovComp
2 days ago
|
|
> Operations like filter and map allocate memory, but that allocation is only necessary if the value escapes. The Swift standard library provides .lazy.map and .lazy.filter, but they don’t work in every case. For logic that only iterates over the filter or map, it’s much more efficient to loop with continue (or use for … in … where) and transform elements into local variables as necessary. It does feel like a compiler/optimiser failure to have to rewrite those cases. |
|
Though, it probably wouldn't work if user code modified the Array prototype.