{"action":"created","comment":{"url":"https://api.github.com/repos/dlang/druntime/pulls/comments/201223618","pull_request_review_id":135681539,"id":201223618,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTIyMzYxOA==","diff_hunk":"@@ -30,6 +30,86 @@ private enum floatCoalesceNaNs = true;\n         assert(hashOf(double.nan) == hashOf(-double.nan)); // Same hash for different NaN.\n }\n \n+private template hasCallableToHash(T)\n+{\n+    static if (is(typeof(((T* x) => (*x).toHash())(null)) HashType))\n+        enum hasCallableToHash = __traits(isIntegral, HashType) && is(HashType : size_t);\n+    else\n+        enum hasCallableToHash = false;\n+}\n+\n+@nogc nothrow pure @safe unittest\n+{\n+    static struct S { size_t toHash() { return 4; } }\n+    assert(hasCallableToHash!S);\n+    assert(!hasCallableToHash!(shared const S));\n+}\n+\n+/+\n+Is it valid to calculate a hash code for T based on the bits of its\n+representation? Always false for classes, interfaces, dynamic arrays,\n+and associative arrays.\n++/\n+private template canBitwiseHash(T)\n+{\n+    static if (is(T EType == enum))\n+        enum canBitwiseHash = .canBitwiseHash!EType;\n+    else static if (is(T == class) || is(T == interface))\n+        enum canBitwiseHash = false;\n+    else static if (is(T == struct))\n+    {\n+        static if (hasCallableToHash!T)\n+            enum canBitwiseHash = false;\n+        else\n+            enum canBitwiseHash = () {\n+                bool result = true;\n+                foreach (U; typeof(T.tupleof))\n+                {\n+                    result &= .canBitwiseHash!U;\n+                    if (!result) return false;\n+                }\n+                return result;\n+                }();\n+    }\n+    else static if (is(T == union))\n+    {\n+        static if (hasCallableToHash!T)\n+            enum canBitwiseHash = false;\n+        else static if (T.tupleof.length == 0)\n+            enum canBitwiseHash = true;\n+        else\n+            enum canBitwiseHash = () {\n+                bool result = false;\n+                foreach (U; typeof(T.tupleof))\n+                {\n+                    result |= .canBitwiseHash!U;\n+                    if (result) return true;\n+                }\n+                return result;\n+                }();\n+    }\n+    else static if (__traits(isAssociativeArray, T))\n+    {\n+        enum canBitwiseHash = false;\n+    }\n+    else static if (is(T == E[], E))\n+    {\n+        static if (__traits(isStaticArray, T))\n+            enum canBitwiseHash = (T.length == 0) || .canBitwiseHash!E;\n+        else\n+            enum canBitwiseHash = false;\n+    }\n+//    // Not currently enforced.\n+//    else static if ((floatCoalesceZeroes || floatCoalesceNaNs) && __traits(isFloating, T))","path":"src/core/internal/hash.d","position":83,"original_position":74,"commit_id":"a949d4098723b9cce7e99f29d9f84d6e1bcdb822","original_commit_id":"48223b74c723f46a5e131f4cb007f4070bf939af","user":{"login":"ZombineDev","id":3475150,"node_id":"MDQ6VXNlcjM0NzUxNTA=","avatar_url":"https://avatars2.githubusercontent.com/u/3475150?v=4","gravatar_id":"","url":"https://api.github.com/users/ZombineDev","html_url":"https://github.com/ZombineDev","followers_url":"https://api.github.com/users/ZombineDev/followers","following_url":"https://api.github.com/users/ZombineDev/following{/other_user}","gists_url":"https://api.github.com/users/ZombineDev/gists{/gist_id}","starred_url":"https://api.github.com/users/ZombineDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZombineDev/subscriptions","organizations_url":"https://api.github.com/users/ZombineDev/orgs","repos_url":"https://api.github.com/users/ZombineDev/repos","events_url":"https://api.github.com/users/ZombineDev/events{/privacy}","received_events_url":"https://api.github.com/users/ZombineDev/received_events","type":"User","site_admin":false},"body":"```D\r\nelse static if (__traits(isFloating, T))\r\n    enum canBitwiseHash = !(floatCoalesceZeroes || floatCoalesceNaNs);\r\n```","created_at":"2018-07-10T05:52:23Z","updated_at":"2018-07-10T05:52:23Z","html_url":"https://github.com/dlang/druntime/pull/2240#discussion_r201223618","pull_request_url":"https://api.github.com/repos/dlang/druntime/pulls/2240","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dlang/druntime/pulls/comments/201223618"},"html":{"href":"https://github.com/dlang/druntime/pull/2240#discussion_r201223618"},"pull_request":{"href":"https://api.github.com/repos/dlang/druntime/pulls/2240"}},"in_reply_to_id":200565200},"pull_request":{"url":"https://api.github.com/repos/dlang/druntime/pulls/2240","id":198878141,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4ODc4MTQx","html_url":"https://github.com/dlang/druntime/pull/2240","diff_url":"https://github.com/dlang/druntime/pull/2240.diff","patch_url":"https://github.com/dlang/druntime/pull/2240.patch","issue_url":"https://api.github.com/repos/dlang/druntime/issues/2240","number":2240,"state":"open","locked":false,"title":"core.internal.hashOf several minor improvements and some refactoring","user":{"login":"n8sh","id":21227491,"node_id":"MDQ6VXNlcjIxMjI3NDkx","avatar_url":"https://avatars2.githubusercontent.com/u/21227491?v=4","gravatar_id":"","url":"https://api.github.com/users/n8sh","html_url":"https://github.com/n8sh","followers_url":"https://api.github.com/users/n8sh/followers","following_url":"https://api.github.com/users/n8sh/following{/other_user}","gists_url":"https://api.github.com/users/n8sh/gists{/gist_id}","starred_url":"https://api.github.com/users/n8sh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n8sh/subscriptions","organizations_url":"https://api.github.com/users/n8sh/orgs","repos_url":"https://api.github.com/users/n8sh/repos","events_url":"https://api.github.com/users/n8sh/events{/privacy}","received_events_url":"https://api.github.com/users/n8sh/received_events","type":"User","site_admin":false},"body":"- Make hash of static arrays more efficient.\r\n- More precise test for when memberwise hashing of structs is necessary (fewer false positives).\r\n- Make required return type of `toHash` less brittle.\r\n- Special handling for structs wrapping a single element (like std.typecons.Typedef).\r\n\r\n_EDIT:_\r\n- Infer `const scope` for some arrays.","created_at":"2018-07-03T07:54:09Z","updated_at":"2018-07-10T05:52:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5465f1a89bb67c4cee1eb5eab65aae777db292d9","assignee":null,"assignees":[],"requested_reviewers":[{"login":"MartinNowak","id":288976,"node_id":"MDQ6VXNlcjI4ODk3Ng==","avatar_url":"https://avatars0.githubusercontent.com/u/288976?v=4","gravatar_id":"","url":"https://api.github.com/users/MartinNowak","html_url":"https://github.com/MartinNowak","followers_url":"https://api.github.com/users/MartinNowak/followers","following_url":"https://api.github.com/users/MartinNowak/following{/other_user}","gists_url":"https://api.github.com/users/MartinNowak/gists{/gist_id}","starred_url":"https://api.github.com/users/MartinNowak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartinNowak/subscriptions","organizations_url":"https://api.github.com/users/MartinNowak/orgs","repos_url":"https://api.github.com/users/MartinNowak/repos","events_url":"https://api.github.com/users/MartinNowak/events{/privacy}","received_events_url":"https://api.github.com/users/MartinNowak/received_events","type":"User","site_admin":false},{"login":"schveiguy","id":580778,"node_id":"MDQ6VXNlcjU4MDc3OA==","avatar_url":"https://avatars0.githubusercontent.com/u/580778?v=4","gravatar_id":"","url":"https://api.github.com/users/schveiguy","html_url":"https://github.com/schveiguy","followers_url":"https://api.github.com/users/schveiguy/followers","following_url":"https://api.github.com/users/schveiguy/following{/other_user}","gists_url":"https://api.github.com/users/schveiguy/gists{/gist_id}","starred_url":"https://api.github.com/users/schveiguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schveiguy/subscriptions","organizations_url":"https://api.github.com/users/schveiguy/orgs","repos_url":"https://api.github.com/users/schveiguy/repos","events_url":"https://api.github.com/users/schveiguy/events{/privacy}","received_events_url":"https://api.github.com/users/schveiguy/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dlang/druntime/pulls/2240/commits","review_comments_url":"https://api.github.com/repos/dlang/druntime/pulls/2240/comments","review_comment_url":"https://api.github.com/repos/dlang/druntime/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dlang/druntime/issues/2240/comments","statuses_url":"https://api.github.com/repos/dlang/druntime/statuses/a949d4098723b9cce7e99f29d9f84d6e1bcdb822","head":{"label":"n8sh:core-hash-misc-improvements","ref":"core-hash-misc-improvements","sha":"a949d4098723b9cce7e99f29d9f84d6e1bcdb822","user":{"login":"n8sh","id":21227491,"node_id":"MDQ6VXNlcjIxMjI3NDkx","avatar_url":"https://avatars2.githubusercontent.com/u/21227491?v=4","gravatar_id":"","url":"https://api.github.com/users/n8sh","html_url":"https://github.com/n8sh","followers_url":"https://api.github.com/users/n8sh/followers","following_url":"https://api.github.com/users/n8sh/following{/other_user}","gists_url":"https://api.github.com/users/n8sh/gists{/gist_id}","starred_url":"https://api.github.com/users/n8sh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n8sh/subscriptions","organizations_url":"https://api.github.com/users/n8sh/orgs","repos_url":"https://api.github.com/users/n8sh/repos","events_url":"https://api.github.com/users/n8sh/events{/privacy}","received_events_url":"https://api.github.com/users/n8sh/received_events","type":"User","site_admin":false},"repo":{"id":112772191,"node_id":"MDEwOlJlcG9zaXRvcnkxMTI3NzIxOTE=","name":"druntime","full_name":"n8sh/druntime","owner":{"login":"n8sh","id":21227491,"node_id":"MDQ6VXNlcjIxMjI3NDkx","avatar_url":"https://avatars2.githubusercontent.com/u/21227491?v=4","gravatar_id":"","url":"https://api.github.com/users/n8sh","html_url":"https://github.com/n8sh","followers_url":"https://api.github.com/users/n8sh/followers","following_url":"https://api.github.com/users/n8sh/following{/other_user}","gists_url":"https://api.github.com/users/n8sh/gists{/gist_id}","starred_url":"https://api.github.com/users/n8sh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n8sh/subscriptions","organizations_url":"https://api.github.com/users/n8sh/orgs","repos_url":"https://api.github.com/users/n8sh/repos","events_url":"https://api.github.com/users/n8sh/events{/privacy}","received_events_url":"https://api.github.com/users/n8sh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/n8sh/druntime","description":"Low level runtime library for the D programming language","fork":true,"url":"https://api.github.com/repos/n8sh/druntime","forks_url":"https://api.github.com/repos/n8sh/druntime/forks","keys_url":"https://api.github.com/repos/n8sh/druntime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/n8sh/druntime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/n8sh/druntime/teams","hooks_url":"https://api.github.com/repos/n8sh/druntime/hooks","issue_events_url":"https://api.github.com/repos/n8sh/druntime/issues/events{/number}","events_url":"https://api.github.com/repos/n8sh/druntime/events","assignees_url":"https://api.github.com/repos/n8sh/druntime/assignees{/user}","branches_url":"https://api.github.com/repos/n8sh/druntime/branches{/branch}","tags_url":"https://api.github.com/repos/n8sh/druntime/tags","blobs_url":"https://api.github.com/repos/n8sh/druntime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/n8sh/druntime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/n8sh/druntime/git/refs{/sha}","trees_url":"https://api.github.com/repos/n8sh/druntime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/n8sh/druntime/statuses/{sha}","languages_url":"https://api.github.com/repos/n8sh/druntime/languages","stargazers_url":"https://api.github.com/repos/n8sh/druntime/stargazers","contributors_url":"https://api.github.com/repos/n8sh/druntime/contributors","subscribers_url":"https://api.github.com/repos/n8sh/druntime/subscribers","subscription_url":"https://api.github.com/repos/n8sh/druntime/subscription","commits_url":"https://api.github.com/repos/n8sh/druntime/commits{/sha}","git_commits_url":"https://api.github.com/repos/n8sh/druntime/git/commits{/sha}","comments_url":"https://api.github.com/repos/n8sh/druntime/comments{/number}","issue_comment_url":"https://api.github.com/repos/n8sh/druntime/issues/comments{/number}","contents_url":"https://api.github.com/repos/n8sh/druntime/contents/{+path}","compare_url":"https://api.github.com/repos/n8sh/druntime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/n8sh/druntime/merges","archive_url":"https://api.github.com/repos/n8sh/druntime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/n8sh/druntime/downloads","issues_url":"https://api.github.com/repos/n8sh/druntime/issues{/number}","pulls_url":"https://api.github.com/repos/n8sh/druntime/pulls{/number}","milestones_url":"https://api.github.com/repos/n8sh/druntime/milestones{/number}","notifications_url":"https://api.github.com/repos/n8sh/druntime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/n8sh/druntime/labels{/name}","releases_url":"https://api.github.com/repos/n8sh/druntime/releases{/id}","deployments_url":"https://api.github.com/repos/n8sh/druntime/deployments","created_at":"2017-12-01T18:16:46Z","updated_at":"2018-07-09T15:26:55Z","pushed_at":"2018-07-09T23:54:31Z","git_url":"git://github.com/n8sh/druntime.git","ssh_url":"git@github.com:n8sh/druntime.git","clone_url":"https://github.com/n8sh/druntime.git","svn_url":"https://github.com/n8sh/druntime","homepage":"dlang.org","size":15214,"stargazers_count":0,"watchers_count":0,"language":"D","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"bsl-1.0","name":"Boost Software License 1.0","spdx_id":"BSL-1.0","url":"https://api.github.com/licenses/bsl-1.0","node_id":"MDc6TGljZW5zZTI4"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dlang:master","ref":"master","sha":"f2f1a0ad724af301efd3b18043077b7c554b2873","user":{"login":"dlang","id":565913,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU2NTkxMw==","avatar_url":"https://avatars3.githubusercontent.com/u/565913?v=4","gravatar_id":"","url":"https://api.github.com/users/dlang","html_url":"https://github.com/dlang","followers_url":"https://api.github.com/users/dlang/followers","following_url":"https://api.github.com/users/dlang/following{/other_user}","gists_url":"https://api.github.com/users/dlang/gists{/gist_id}","starred_url":"https://api.github.com/users/dlang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlang/subscriptions","organizations_url":"https://api.github.com/users/dlang/orgs","repos_url":"https://api.github.com/users/dlang/repos","events_url":"https://api.github.com/users/dlang/events{/privacy}","received_events_url":"https://api.github.com/users/dlang/received_events","type":"Organization","site_admin":false},"repo":{"id":1257087,"node_id":"MDEwOlJlcG9zaXRvcnkxMjU3MDg3","name":"druntime","full_name":"dlang/druntime","owner":{"login":"dlang","id":565913,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU2NTkxMw==","avatar_url":"https://avatars3.githubusercontent.com/u/565913?v=4","gravatar_id":"","url":"https://api.github.com/users/dlang","html_url":"https://github.com/dlang","followers_url":"https://api.github.com/users/dlang/followers","following_url":"https://api.github.com/users/dlang/following{/other_user}","gists_url":"https://api.github.com/users/dlang/gists{/gist_id}","starred_url":"https://api.github.com/users/dlang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlang/subscriptions","organizations_url":"https://api.github.com/users/dlang/orgs","repos_url":"https://api.github.com/users/dlang/repos","events_url":"https://api.github.com/users/dlang/events{/privacy}","received_events_url":"https://api.github.com/users/dlang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dlang/druntime","description":"Low level runtime library for the D programming language","fork":false,"url":"https://api.github.com/repos/dlang/druntime","forks_url":"https://api.github.com/repos/dlang/druntime/forks","keys_url":"https://api.github.com/repos/dlang/druntime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dlang/druntime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dlang/druntime/teams","hooks_url":"https://api.github.com/repos/dlang/druntime/hooks","issue_events_url":"https://api.github.com/repos/dlang/druntime/issues/events{/number}","events_url":"https://api.github.com/repos/dlang/druntime/events","assignees_url":"https://api.github.com/repos/dlang/druntime/assignees{/user}","branches_url":"https://api.github.com/repos/dlang/druntime/branches{/branch}","tags_url":"https://api.github.com/repos/dlang/druntime/tags","blobs_url":"https://api.github.com/repos/dlang/druntime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dlang/druntime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dlang/druntime/git/refs{/sha}","trees_url":"https://api.github.com/repos/dlang/druntime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dlang/druntime/statuses/{sha}","languages_url":"https://api.github.com/repos/dlang/druntime/languages","stargazers_url":"https://api.github.com/repos/dlang/druntime/stargazers","contributors_url":"https://api.github.com/repos/dlang/druntime/contributors","subscribers_url":"https://api.github.com/repos/dlang/druntime/subscribers","subscription_url":"https://api.github.com/repos/dlang/druntime/subscription","commits_url":"https://api.github.com/repos/dlang/druntime/commits{/sha}","git_commits_url":"https://api.github.com/repos/dlang/druntime/git/commits{/sha}","comments_url":"https://api.github.com/repos/dlang/druntime/comments{/number}","issue_comment_url":"https://api.github.com/repos/dlang/druntime/issues/comments{/number}","contents_url":"https://api.github.com/repos/dlang/druntime/contents/{+path}","compare_url":"https://api.github.com/repos/dlang/druntime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dlang/druntime/merges","archive_url":"https://api.github.com/repos/dlang/druntime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dlang/druntime/downloads","issues_url":"https://api.github.com/repos/dlang/druntime/issues{/number}","pulls_url":"https://api.github.com/repos/dlang/druntime/pulls{/number}","milestones_url":"https://api.github.com/repos/dlang/druntime/milestones{/number}","notifications_url":"https://api.github.com/repos/dlang/druntime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dlang/druntime/labels{/name}","releases_url":"https://api.github.com/repos/dlang/druntime/releases{/id}","deployments_url":"https://api.github.com/repos/dlang/druntime/deployments","created_at":"2011-01-15T07:01:38Z","updated_at":"2018-07-09T13:40:09Z","pushed_at":"2018-07-09T23:54:33Z","git_url":"git://github.com/dlang/druntime.git","ssh_url":"git@github.com:dlang/druntime.git","clone_url":"https://github.com/dlang/druntime.git","svn_url":"https://github.com/dlang/druntime","homepage":"dlang.org","size":15228,"stargazers_count":484,"watchers_count":484,"language":"D","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":332,"mirror_url":null,"archived":false,"open_issues_count":67,"license":{"key":"bsl-1.0","name":"Boost Software License 1.0","spdx_id":"BSL-1.0","url":"https://api.github.com/licenses/bsl-1.0","node_id":"MDc6TGljZW5zZTI4"},"forks":332,"open_issues":67,"watchers":484,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dlang/druntime/pulls/2240"},"html":{"href":"https://github.com/dlang/druntime/pull/2240"},"issue":{"href":"https://api.github.com/repos/dlang/druntime/issues/2240"},"comments":{"href":"https://api.github.com/repos/dlang/druntime/issues/2240/comments"},"review_comments":{"href":"https://api.github.com/repos/dlang/druntime/pulls/2240/comments"},"review_comment":{"href":"https://api.github.com/repos/dlang/druntime/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dlang/druntime/pulls/2240/commits"},"statuses":{"href":"https://api.github.com/repos/dlang/druntime/statuses/a949d4098723b9cce7e99f29d9f84d6e1bcdb822"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ZombineDev"}}