Correct. We don't do this only because we're being cautious about lifetimes. If we had a reliable way of detecting that the copy is unnecessary, it would be a significant win.
Clang has actually implemented an optimization where it eliminates the copying logic from `noescape` blocks entirely, essentially generating them as global blocks that happen to be allocated on the stack.
Additional Detail from JIRA
When we pass closures to @NoEscape objective c block arguments the closures are allocated on the heap. We should also stack allocate them.
The text was updated successfully, but these errors were encountered: