{"action":"created","comment":{"url":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/comments/176892994","pull_request_review_id":106681657,"id":176892994,"diff_hunk":"@@ -198,6 +210,19 @@ let rec caml_compare (a : Obj.t) (b : Obj.t) : int =\n         else\n           let len_a = Bs_obj.length a in\n           let len_b = Bs_obj.length b in\n+          if len_a = 0 && len_b = 0 && O.is_object a && O.is_object b then\n+            begin\n+              let keys_a = O.keys a in\n+              let keys_b = O.keys b in\n+              O.sort(keys_a);\n+              O.sort(keys_b);\n+              let len_a = O.length keys_a in\n+              let len_b = O.length keys_b in\n+              let min_len = min len_a len_b in\n+              let default_res = len_a - len_b in\n+              aux_obj_compare a keys_a b keys_b 0 min_len default_res\n+            end\n+        else\n           if len_a = len_b then\n             aux_same_length a b 0 len_a","path":"jscomp/runtime/caml_obj.ml","position":37,"original_position":37,"commit_id":"e665fecd3cc0e3edfd8ac76d69846fd0be9db833","original_commit_id":"e665fecd3cc0e3edfd8ac76d69846fd0be9db833","user":{"login":"bobzhang","id":747051,"avatar_url":"https://avatars0.githubusercontent.com/u/747051?v=4","gravatar_id":"","url":"https://api.github.com/users/bobzhang","html_url":"https://github.com/bobzhang","followers_url":"https://api.github.com/users/bobzhang/followers","following_url":"https://api.github.com/users/bobzhang/following{/other_user}","gists_url":"https://api.github.com/users/bobzhang/gists{/gist_id}","starred_url":"https://api.github.com/users/bobzhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobzhang/subscriptions","organizations_url":"https://api.github.com/users/bobzhang/orgs","repos_url":"https://api.github.com/users/bobzhang/repos","events_url":"https://api.github.com/users/bobzhang/events{/privacy}","received_events_url":"https://api.github.com/users/bobzhang/received_events","type":"User","site_admin":false},"body":"shall we put this branch earlier, this branch seems to be hit more often than the previous one? Is it okay to assume `Array.isArray` API exists? (cc @chenglou )\r\n```\r\nif len_a = len_b && is_array a \r\n```\r\nIn that case, we don't need `o.constructor == Object`","created_at":"2018-03-24T00:35:40Z","updated_at":"2018-03-24T00:37:44Z","html_url":"https://github.com/BuckleScript/bucklescript/pull/2657#discussion_r176892994","pull_request_url":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/2657","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/comments/176892994"},"html":{"href":"https://github.com/BuckleScript/bucklescript/pull/2657#discussion_r176892994"},"pull_request":{"href":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/2657"}}},"pull_request":{"url":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/2657","id":175998889,"html_url":"https://github.com/BuckleScript/bucklescript/pull/2657","diff_url":"https://github.com/BuckleScript/bucklescript/pull/2657.diff","patch_url":"https://github.com/BuckleScript/bucklescript/pull/2657.patch","issue_url":"https://api.github.com/repos/BuckleScript/bucklescript/issues/2657","number":2657,"state":"open","locked":false,"title":"Extend polymorphic compare to support objects.","user":{"login":"cristianoc","id":7965335,"avatar_url":"https://avatars3.githubusercontent.com/u/7965335?v=4","gravatar_id":"","url":"https://api.github.com/users/cristianoc","html_url":"https://github.com/cristianoc","followers_url":"https://api.github.com/users/cristianoc/followers","following_url":"https://api.github.com/users/cristianoc/following{/other_user}","gists_url":"https://api.github.com/users/cristianoc/gists{/gist_id}","starred_url":"https://api.github.com/users/cristianoc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cristianoc/subscriptions","organizations_url":"https://api.github.com/users/cristianoc/orgs","repos_url":"https://api.github.com/users/cristianoc/repos","events_url":"https://api.github.com/users/cristianoc/events{/privacy}","received_events_url":"https://api.github.com/users/cristianoc/received_events","type":"User","site_admin":false},"body":"Extend polymorphic compare to support objects created as e.g. `[%bs.obj {x=1; y=2}]`.\r\n\r\nThe comparison of `{x:1, y:2}` and `{x:3, y:4}` is defined logically as if the objects were lists of pairs: the first keys are compared, then the first values, then the second keys, then the second values, etc.\r\nIn particular, the order of keys matters, and `{x:1, y:2}` is different from `{y:2, x:1}`.\r\n\r\nTODO: equality and hash.\r\n\r\nObjects, when viewed as blocks, have size 0 and no tag.\r\nHere an object `o` is recognized by checking that `o.constructor === Object`.\r\nThen, the keys and values can be extracted.\r\n\r\nThe compare function keeps the same structure, with one extra while loop, and does not change unless objects are encountered. Presumably `Object.keys(o)` performs some allocation.","created_at":"2018-03-19T19:15:34Z","updated_at":"2018-03-24T00:37:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8e68322531d2d9da3701f1f225306f69d9ccbe00","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":435575357,"url":"https://api.github.com/repos/BuckleScript/bucklescript/labels/PRIORITY:HIGH","name":"PRIORITY:HIGH","color":"b60205","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/2657/commits","review_comments_url":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/2657/comments","review_comment_url":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BuckleScript/bucklescript/issues/2657/comments","statuses_url":"https://api.github.com/repos/BuckleScript/bucklescript/statuses/e665fecd3cc0e3edfd8ac76d69846fd0be9db833","head":{"label":"cristianoc:polymorphic_compare_objects","ref":"polymorphic_compare_objects","sha":"e665fecd3cc0e3edfd8ac76d69846fd0be9db833","user":{"login":"cristianoc","id":7965335,"avatar_url":"https://avatars3.githubusercontent.com/u/7965335?v=4","gravatar_id":"","url":"https://api.github.com/users/cristianoc","html_url":"https://github.com/cristianoc","followers_url":"https://api.github.com/users/cristianoc/followers","following_url":"https://api.github.com/users/cristianoc/following{/other_user}","gists_url":"https://api.github.com/users/cristianoc/gists{/gist_id}","starred_url":"https://api.github.com/users/cristianoc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cristianoc/subscriptions","organizations_url":"https://api.github.com/users/cristianoc/orgs","repos_url":"https://api.github.com/users/cristianoc/repos","events_url":"https://api.github.com/users/cristianoc/events{/privacy}","received_events_url":"https://api.github.com/users/cristianoc/received_events","type":"User","site_admin":false},"repo":{"id":103414746,"name":"bucklescript","full_name":"cristianoc/bucklescript","owner":{"login":"cristianoc","id":7965335,"avatar_url":"https://avatars3.githubusercontent.com/u/7965335?v=4","gravatar_id":"","url":"https://api.github.com/users/cristianoc","html_url":"https://github.com/cristianoc","followers_url":"https://api.github.com/users/cristianoc/followers","following_url":"https://api.github.com/users/cristianoc/following{/other_user}","gists_url":"https://api.github.com/users/cristianoc/gists{/gist_id}","starred_url":"https://api.github.com/users/cristianoc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cristianoc/subscriptions","organizations_url":"https://api.github.com/users/cristianoc/orgs","repos_url":"https://api.github.com/users/cristianoc/repos","events_url":"https://api.github.com/users/cristianoc/events{/privacy}","received_events_url":"https://api.github.com/users/cristianoc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cristianoc/bucklescript","description":"A backend for the OCaml compiler which emits JavaScript.","fork":true,"url":"https://api.github.com/repos/cristianoc/bucklescript","forks_url":"https://api.github.com/repos/cristianoc/bucklescript/forks","keys_url":"https://api.github.com/repos/cristianoc/bucklescript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cristianoc/bucklescript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cristianoc/bucklescript/teams","hooks_url":"https://api.github.com/repos/cristianoc/bucklescript/hooks","issue_events_url":"https://api.github.com/repos/cristianoc/bucklescript/issues/events{/number}","events_url":"https://api.github.com/repos/cristianoc/bucklescript/events","assignees_url":"https://api.github.com/repos/cristianoc/bucklescript/assignees{/user}","branches_url":"https://api.github.com/repos/cristianoc/bucklescript/branches{/branch}","tags_url":"https://api.github.com/repos/cristianoc/bucklescript/tags","blobs_url":"https://api.github.com/repos/cristianoc/bucklescript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cristianoc/bucklescript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cristianoc/bucklescript/git/refs{/sha}","trees_url":"https://api.github.com/repos/cristianoc/bucklescript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cristianoc/bucklescript/statuses/{sha}","languages_url":"https://api.github.com/repos/cristianoc/bucklescript/languages","stargazers_url":"https://api.github.com/repos/cristianoc/bucklescript/stargazers","contributors_url":"https://api.github.com/repos/cristianoc/bucklescript/contributors","subscribers_url":"https://api.github.com/repos/cristianoc/bucklescript/subscribers","subscription_url":"https://api.github.com/repos/cristianoc/bucklescript/subscription","commits_url":"https://api.github.com/repos/cristianoc/bucklescript/commits{/sha}","git_commits_url":"https://api.github.com/repos/cristianoc/bucklescript/git/commits{/sha}","comments_url":"https://api.github.com/repos/cristianoc/bucklescript/comments{/number}","issue_comment_url":"https://api.github.com/repos/cristianoc/bucklescript/issues/comments{/number}","contents_url":"https://api.github.com/repos/cristianoc/bucklescript/contents/{+path}","compare_url":"https://api.github.com/repos/cristianoc/bucklescript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cristianoc/bucklescript/merges","archive_url":"https://api.github.com/repos/cristianoc/bucklescript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cristianoc/bucklescript/downloads","issues_url":"https://api.github.com/repos/cristianoc/bucklescript/issues{/number}","pulls_url":"https://api.github.com/repos/cristianoc/bucklescript/pulls{/number}","milestones_url":"https://api.github.com/repos/cristianoc/bucklescript/milestones{/number}","notifications_url":"https://api.github.com/repos/cristianoc/bucklescript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cristianoc/bucklescript/labels{/name}","releases_url":"https://api.github.com/repos/cristianoc/bucklescript/releases{/id}","deployments_url":"https://api.github.com/repos/cristianoc/bucklescript/deployments","created_at":"2017-09-13T15:07:25Z","updated_at":"2017-09-13T15:07:32Z","pushed_at":"2018-03-23T18:50:30Z","git_url":"git://github.com/cristianoc/bucklescript.git","ssh_url":"git@github.com:cristianoc/bucklescript.git","clone_url":"https://github.com/cristianoc/bucklescript.git","svn_url":"https://github.com/cristianoc/bucklescript","homepage":"","size":162105,"stargazers_count":0,"watchers_count":0,"language":"OCaml","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"BuckleScript:master","ref":"master","sha":"5c38c8030df5ffe0fb064d49e8f9c8a960522ed5","user":{"login":"BuckleScript","id":29257325,"avatar_url":"https://avatars3.githubusercontent.com/u/29257325?v=4","gravatar_id":"","url":"https://api.github.com/users/BuckleScript","html_url":"https://github.com/BuckleScript","followers_url":"https://api.github.com/users/BuckleScript/followers","following_url":"https://api.github.com/users/BuckleScript/following{/other_user}","gists_url":"https://api.github.com/users/BuckleScript/gists{/gist_id}","starred_url":"https://api.github.com/users/BuckleScript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BuckleScript/subscriptions","organizations_url":"https://api.github.com/users/BuckleScript/orgs","repos_url":"https://api.github.com/users/BuckleScript/repos","events_url":"https://api.github.com/users/BuckleScript/events{/privacy}","received_events_url":"https://api.github.com/users/BuckleScript/received_events","type":"Organization","site_admin":false},"repo":{"id":49159983,"name":"bucklescript","full_name":"BuckleScript/bucklescript","owner":{"login":"BuckleScript","id":29257325,"avatar_url":"https://avatars3.githubusercontent.com/u/29257325?v=4","gravatar_id":"","url":"https://api.github.com/users/BuckleScript","html_url":"https://github.com/BuckleScript","followers_url":"https://api.github.com/users/BuckleScript/followers","following_url":"https://api.github.com/users/BuckleScript/following{/other_user}","gists_url":"https://api.github.com/users/BuckleScript/gists{/gist_id}","starred_url":"https://api.github.com/users/BuckleScript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BuckleScript/subscriptions","organizations_url":"https://api.github.com/users/BuckleScript/orgs","repos_url":"https://api.github.com/users/BuckleScript/repos","events_url":"https://api.github.com/users/BuckleScript/events{/privacy}","received_events_url":"https://api.github.com/users/BuckleScript/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BuckleScript/bucklescript","description":"A backend for the OCaml compiler which emits JavaScript.","fork":false,"url":"https://api.github.com/repos/BuckleScript/bucklescript","forks_url":"https://api.github.com/repos/BuckleScript/bucklescript/forks","keys_url":"https://api.github.com/repos/BuckleScript/bucklescript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BuckleScript/bucklescript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BuckleScript/bucklescript/teams","hooks_url":"https://api.github.com/repos/BuckleScript/bucklescript/hooks","issue_events_url":"https://api.github.com/repos/BuckleScript/bucklescript/issues/events{/number}","events_url":"https://api.github.com/repos/BuckleScript/bucklescript/events","assignees_url":"https://api.github.com/repos/BuckleScript/bucklescript/assignees{/user}","branches_url":"https://api.github.com/repos/BuckleScript/bucklescript/branches{/branch}","tags_url":"https://api.github.com/repos/BuckleScript/bucklescript/tags","blobs_url":"https://api.github.com/repos/BuckleScript/bucklescript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BuckleScript/bucklescript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BuckleScript/bucklescript/git/refs{/sha}","trees_url":"https://api.github.com/repos/BuckleScript/bucklescript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BuckleScript/bucklescript/statuses/{sha}","languages_url":"https://api.github.com/repos/BuckleScript/bucklescript/languages","stargazers_url":"https://api.github.com/repos/BuckleScript/bucklescript/stargazers","contributors_url":"https://api.github.com/repos/BuckleScript/bucklescript/contributors","subscribers_url":"https://api.github.com/repos/BuckleScript/bucklescript/subscribers","subscription_url":"https://api.github.com/repos/BuckleScript/bucklescript/subscription","commits_url":"https://api.github.com/repos/BuckleScript/bucklescript/commits{/sha}","git_commits_url":"https://api.github.com/repos/BuckleScript/bucklescript/git/commits{/sha}","comments_url":"https://api.github.com/repos/BuckleScript/bucklescript/comments{/number}","issue_comment_url":"https://api.github.com/repos/BuckleScript/bucklescript/issues/comments{/number}","contents_url":"https://api.github.com/repos/BuckleScript/bucklescript/contents/{+path}","compare_url":"https://api.github.com/repos/BuckleScript/bucklescript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BuckleScript/bucklescript/merges","archive_url":"https://api.github.com/repos/BuckleScript/bucklescript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BuckleScript/bucklescript/downloads","issues_url":"https://api.github.com/repos/BuckleScript/bucklescript/issues{/number}","pulls_url":"https://api.github.com/repos/BuckleScript/bucklescript/pulls{/number}","milestones_url":"https://api.github.com/repos/BuckleScript/bucklescript/milestones{/number}","notifications_url":"https://api.github.com/repos/BuckleScript/bucklescript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BuckleScript/bucklescript/labels{/name}","releases_url":"https://api.github.com/repos/BuckleScript/bucklescript/releases{/id}","deployments_url":"https://api.github.com/repos/BuckleScript/bucklescript/deployments","created_at":"2016-01-06T20:34:59Z","updated_at":"2018-03-23T17:09:36Z","pushed_at":"2018-03-23T18:50:32Z","git_url":"git://github.com/BuckleScript/bucklescript.git","ssh_url":"git@github.com:BuckleScript/bucklescript.git","clone_url":"https://github.com/BuckleScript/bucklescript.git","svn_url":"https://github.com/BuckleScript/bucklescript","homepage":"https://bucklescript.github.io","size":218423,"stargazers_count":3501,"watchers_count":3501,"language":"OCaml","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":224,"mirror_url":null,"archived":false,"open_issues_count":336,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":224,"open_issues":336,"watchers":3501,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/2657"},"html":{"href":"https://github.com/BuckleScript/bucklescript/pull/2657"},"issue":{"href":"https://api.github.com/repos/BuckleScript/bucklescript/issues/2657"},"comments":{"href":"https://api.github.com/repos/BuckleScript/bucklescript/issues/2657/comments"},"review_comments":{"href":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/2657/comments"},"review_comment":{"href":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BuckleScript/bucklescript/pulls/2657/commits"},"statuses":{"href":"https://api.github.com/repos/BuckleScript/bucklescript/statuses/e665fecd3cc0e3edfd8ac76d69846fd0be9db833"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"bobzhang"}}