Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Swift 2.3] Add @noescape to appropriate closures, matching the Swift3 branch's behavior #130

Merged
merged 1 commit into from
Sep 27, 2016
Merged

[Swift 2.3] Add @noescape to appropriate closures, matching the Swift3 branch's behavior #130

merged 1 commit into from
Sep 27, 2016

Conversation

swiftlyfalling
Copy link
Collaborator

This PR adds some @noescape markers for closures in the Swift 2.3 branch. (Matching the default behavior of the Swift3 branch.)

This should result in:

  • additional compiler optimizations / small performance gains
  • no need to explicitly capture self (weakly or otherwise) in synchronous methods like .writeInTransaction
  • explicit matching of the Swift3 branch's closure escaping behavior for those methods, easing forward/back migration between the Swift 2.3/Swift 3 branches of GRDB

This also should be a fully backwards-compatible change.

@groue
Copy link
Owner

groue commented Sep 27, 2016

Hello @swiftlyfalling! Thanks for this new contribution!

Xcode 8 doesn't generate any warning related to @NoEscape closures in the Swift2.3 branch. Does this pull request target Xcode 8.1 beta? Or can it be safely used with Xcode 8 and merged right away?

@swiftlyfalling
Copy link
Collaborator Author

swiftlyfalling commented Sep 27, 2016

@groue: This can be safely used with Xcode 8 and merged right away.

Just to clarify - this PR actually has to do with fixing the escaping behavior of the closures to match up between the branches:
-Swift 1/2 defaults to "escaping" closures (unless marked @noescape).
-Swift 3 defaults to "non-escaping" closures (unless marked by @escaping).

Because of the prior default, the Swift 2.3 (and earlier) branches had some unmarked closures that were unnecessarily defaulting to "escaping", when they could have been "non-escaping".

In the Swift 3 branch, these unmarked closures are now "non-escaping" closures. Since they always could have been, this PR explicitly fixes it in the Swift 2.3 branch.

@groue groue merged commit 2c29650 into groue:Swift2.3 Sep 27, 2016
@groue
Copy link
Owner

groue commented Sep 27, 2016

A big thank you, as always!

@groue
Copy link
Owner

groue commented Sep 27, 2016

(I'll ship version 0.81.2 shortly)

@groue
Copy link
Owner

groue commented Sep 28, 2016

There we go, v0.81.2 is out!

@swiftlyfalling swiftlyfalling deleted the swift23/noescape_changes_to_match_swift3 branch September 29, 2016 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants