Skip to content

[5.0] Overlays: Modernize hashing for Selector and CGFloat #21464

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

Closed

Conversation

lorentey
Copy link
Member

(Cherry-picked from #20872 and #20873)

These fix two low-hanging deprecation warnings (introduced by #21445) in the overlays.

Foundation still generates a bunch of these; however, these two are particularly easy to fix, and should lead to a nice speedup, so we should just do it.

rdar://problem/43394032

…zed versions

`Selector.==` currently calls `sel_isEqual`, which is documented to be the same as == on the direct pointer values. We can safely replace the explicit implementation with the compiler-generated one.

`Selector.hashValue` is deprecated as a Hashable requirement, and the preferred method to implement is `hash(into:)`. Implementing the proper function improves hashing performance by eliminating nested Hasher sessions.

By removing the previous definition of `hashValue`, we allow the compiler to synthesize the correct `hash(into:)` (and `hashValue`) implementations.

(cherry picked from commit 4e2dfb7)
This replaces the previously compiler-synthesized implementation with one that directly feeds the wrapped value to the hasher. The new definition is functionally equivalent, but warning-free and faster.

(cherry picked from commit 7327d5d)
This makes for a small speedup, bringing CGFloat hashing to the same speed as direct Float/Double.

(cherry picked from commit b58d3d1)
@lorentey lorentey requested a review from a team as a code owner December 20, 2018 18:08
@lorentey
Copy link
Member Author

@swift-ci test

@lorentey lorentey changed the title Overlays: Modernize hashing for Selector and CGFloat [5.0] Overlays: Modernize hashing for Selector and CGFloat Jan 7, 2019
@jrose-apple
Copy link
Contributor

Post-break ping.

@lorentey
Copy link
Member Author

lorentey commented Jan 8, 2019

Hm, I suspect these have missed the boat for 5.0.

The changes here aren't ABI-breaking, so we can easily defer them for later, along with the overlays' other hashValue definitions. (CGFloat's new rawHashValue definition changes the code path it takes for hashing, but it produces the same hashes as hash(into:). So code compiled for the 5.0 stdlib will be able to coexist with code that's compiled with this change in place.)

@lorentey lorentey closed this Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants