Eliminate the need for shared static this() on Posix#7529
Eliminate the need for shared static this() on Posix#7529andralex wants to merge 2 commits intodlang:masterfrom
Conversation
|
Thanks for your pull request, @andralex! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#7529" |
std/socket.d
Outdated
| { | ||
| enum getnameinfoPointer = &getnameinfo; | ||
| enum getaddrinfoPointer = &getaddrinfo; | ||
| enum freeaddrinfoPointer = &freeaddrinfo; |
There was a problem hiding this comment.
Remove these for Posix, add version(Windows) { ... } else version(Posix) { ... } else static assert(0); where applicable to avoid un-necessary indirections.
There was a problem hiding this comment.
Thanks, I'll add the assert. To get rid of the enums I'd need to wait for the updated Windows version.
There was a problem hiding this comment.
Update: I see there's a static assert on line 126, so no need to duplicate that.
There was a problem hiding this comment.
Just checked, only dmd generates actual indirections :). https://godbolt.org/z/RmDYYV
There was a problem hiding this comment.
Even better: I consolidated those to the top version blocks.
|
I had flashbacks that I worked on that before... and indeed I did: #5813. Let's continue there. |
It would be great if we could eliminate all static ctors/dtors from Phobos and use lazy initialization instead. This PR is a simple step in that direction - there's really no need to initialize those pointers to function (or test them) in Posix.