{"action":"opened","number":1537,"pull_request":{"url":"https://api.github.com/repos/ruby/ruby/pulls/1537","id":110347770,"html_url":"https://github.com/ruby/ruby/pull/1537","diff_url":"https://github.com/ruby/ruby/pull/1537.diff","patch_url":"https://github.com/ruby/ruby/pull/1537.patch","issue_url":"https://api.github.com/repos/ruby/ruby/issues/1537","number":1537,"state":"open","locked":false,"title":"Improve performance of implicit type conversion","user":{"login":"Watson1978","id":199156,"avatar_url":"https://avatars1.githubusercontent.com/u/199156?v=3","gravatar_id":"","url":"https://api.github.com/users/Watson1978","html_url":"https://github.com/Watson1978","followers_url":"https://api.github.com/users/Watson1978/followers","following_url":"https://api.github.com/users/Watson1978/following{/other_user}","gists_url":"https://api.github.com/users/Watson1978/gists{/gist_id}","starred_url":"https://api.github.com/users/Watson1978/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Watson1978/subscriptions","organizations_url":"https://api.github.com/users/Watson1978/orgs","repos_url":"https://api.github.com/users/Watson1978/repos","events_url":"https://api.github.com/users/Watson1978/events{/privacy}","received_events_url":"https://api.github.com/users/Watson1978/received_events","type":"User","site_admin":false},"body":"At least, Array#flatten will be faster around 20%.\r\nSeems that strncmp() & strcmp() in convert_type() are slightly heavy to look up the method's id for type conversion.\r\n(https://github.com/ruby/ruby/blob/4f2db15b42d7b8eb5b304a92ba2296632dba3edf/object.c#L2634-L2643)\r\n\r\nThis patch will use known method's id directly.\r\n\r\n* Before\r\n```\r\n                                             user     system      total        real\r\nArray#flatten (rb_check_convert_type2)   1.000000   0.000000   1.000000 (  1.001917)\r\nArray#+ (rb_convert_type2)               1.010000   0.000000   1.010000 (  1.006383)\r\n```\r\n\r\n* After\r\n```\r\n                                             user     system      total        real\r\nArray#flatten (rb_check_convert_type2)   0.830000   0.000000   0.830000 (  0.833411)\r\nArray#+ (rb_convert_type2)               0.950000   0.000000   0.950000 (  0.953832)\r\n```\r\n\r\n* Test Code\r\n```\r\nrequire 'benchmark'\r\n\r\nBenchmark.bmbm do |x|\r\n\r\n  ary = []\r\n  100.times { |i| ary << i }\r\n  array = [ary]\r\n\r\n  x.report \"Array#flatten (rb_check_convert_type2)\"do\r\n    100000.times do\r\n      array.flatten\r\n    end\r\n  end\r\n\r\n  x.report \"Array#+ (rb_convert_type2)\"do\r\n    class Foo\r\n      def to_ary\r\n        [1,2,3]\r\n      end\r\n    end\r\n    obj = Foo.new\r\n\r\n    2000000.times do\r\n      array + obj\r\n    end\r\n  end\r\n\r\nend\r\n```","created_at":"2017-03-13T06:48:19Z","updated_at":"2017-03-13T06:48:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ruby/ruby/pulls/1537/commits","review_comments_url":"https://api.github.com/repos/ruby/ruby/pulls/1537/comments","review_comment_url":"https://api.github.com/repos/ruby/ruby/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ruby/ruby/issues/1537/comments","statuses_url":"https://api.github.com/repos/ruby/ruby/statuses/2207b096004ebf85b99641b1c6a9d4bf27a4c3b0","head":{"label":"Watson1978:type_convert","ref":"type_convert","sha":"2207b096004ebf85b99641b1c6a9d4bf27a4c3b0","user":{"login":"Watson1978","id":199156,"avatar_url":"https://avatars1.githubusercontent.com/u/199156?v=3","gravatar_id":"","url":"https://api.github.com/users/Watson1978","html_url":"https://github.com/Watson1978","followers_url":"https://api.github.com/users/Watson1978/followers","following_url":"https://api.github.com/users/Watson1978/following{/other_user}","gists_url":"https://api.github.com/users/Watson1978/gists{/gist_id}","starred_url":"https://api.github.com/users/Watson1978/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Watson1978/subscriptions","organizations_url":"https://api.github.com/users/Watson1978/orgs","repos_url":"https://api.github.com/users/Watson1978/repos","events_url":"https://api.github.com/users/Watson1978/events{/privacy}","received_events_url":"https://api.github.com/users/Watson1978/received_events","type":"User","site_admin":false},"repo":{"id":83974305,"name":"ruby","full_name":"Watson1978/ruby","owner":{"login":"Watson1978","id":199156,"avatar_url":"https://avatars1.githubusercontent.com/u/199156?v=3","gravatar_id":"","url":"https://api.github.com/users/Watson1978","html_url":"https://github.com/Watson1978","followers_url":"https://api.github.com/users/Watson1978/followers","following_url":"https://api.github.com/users/Watson1978/following{/other_user}","gists_url":"https://api.github.com/users/Watson1978/gists{/gist_id}","starred_url":"https://api.github.com/users/Watson1978/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Watson1978/subscriptions","organizations_url":"https://api.github.com/users/Watson1978/orgs","repos_url":"https://api.github.com/users/Watson1978/repos","events_url":"https://api.github.com/users/Watson1978/events{/privacy}","received_events_url":"https://api.github.com/users/Watson1978/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Watson1978/ruby","description":"The Ruby Programming Language","fork":true,"url":"https://api.github.com/repos/Watson1978/ruby","forks_url":"https://api.github.com/repos/Watson1978/ruby/forks","keys_url":"https://api.github.com/repos/Watson1978/ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Watson1978/ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Watson1978/ruby/teams","hooks_url":"https://api.github.com/repos/Watson1978/ruby/hooks","issue_events_url":"https://api.github.com/repos/Watson1978/ruby/issues/events{/number}","events_url":"https://api.github.com/repos/Watson1978/ruby/events","assignees_url":"https://api.github.com/repos/Watson1978/ruby/assignees{/user}","branches_url":"https://api.github.com/repos/Watson1978/ruby/branches{/branch}","tags_url":"https://api.github.com/repos/Watson1978/ruby/tags","blobs_url":"https://api.github.com/repos/Watson1978/ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Watson1978/ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Watson1978/ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/Watson1978/ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Watson1978/ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/Watson1978/ruby/languages","stargazers_url":"https://api.github.com/repos/Watson1978/ruby/stargazers","contributors_url":"https://api.github.com/repos/Watson1978/ruby/contributors","subscribers_url":"https://api.github.com/repos/Watson1978/ruby/subscribers","subscription_url":"https://api.github.com/repos/Watson1978/ruby/subscription","commits_url":"https://api.github.com/repos/Watson1978/ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/Watson1978/ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/Watson1978/ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/Watson1978/ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/Watson1978/ruby/contents/{+path}","compare_url":"https://api.github.com/repos/Watson1978/ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Watson1978/ruby/merges","archive_url":"https://api.github.com/repos/Watson1978/ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Watson1978/ruby/downloads","issues_url":"https://api.github.com/repos/Watson1978/ruby/issues{/number}","pulls_url":"https://api.github.com/repos/Watson1978/ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/Watson1978/ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/Watson1978/ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Watson1978/ruby/labels{/name}","releases_url":"https://api.github.com/repos/Watson1978/ruby/releases{/id}","deployments_url":"https://api.github.com/repos/Watson1978/ruby/deployments","created_at":"2017-03-05T14:01:25Z","updated_at":"2017-03-05T14:01:43Z","pushed_at":"2017-03-13T06:45:59Z","git_url":"git://github.com/Watson1978/ruby.git","ssh_url":"git@github.com:Watson1978/ruby.git","clone_url":"https://github.com/Watson1978/ruby.git","svn_url":"https://github.com/Watson1978/ruby","homepage":"http://www.ruby-lang.org/","size":141863,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"ruby:trunk","ref":"trunk","sha":"65285fbdb898a6c19b4115ba337b4cf4298dc05f","user":{"login":"ruby","id":210414,"avatar_url":"https://avatars0.githubusercontent.com/u/210414?v=3","gravatar_id":"","url":"https://api.github.com/users/ruby","html_url":"https://github.com/ruby","followers_url":"https://api.github.com/users/ruby/followers","following_url":"https://api.github.com/users/ruby/following{/other_user}","gists_url":"https://api.github.com/users/ruby/gists{/gist_id}","starred_url":"https://api.github.com/users/ruby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruby/subscriptions","organizations_url":"https://api.github.com/users/ruby/orgs","repos_url":"https://api.github.com/users/ruby/repos","events_url":"https://api.github.com/users/ruby/events{/privacy}","received_events_url":"https://api.github.com/users/ruby/received_events","type":"Organization","site_admin":false},"repo":{"id":538746,"name":"ruby","full_name":"ruby/ruby","owner":{"login":"ruby","id":210414,"avatar_url":"https://avatars0.githubusercontent.com/u/210414?v=3","gravatar_id":"","url":"https://api.github.com/users/ruby","html_url":"https://github.com/ruby","followers_url":"https://api.github.com/users/ruby/followers","following_url":"https://api.github.com/users/ruby/following{/other_user}","gists_url":"https://api.github.com/users/ruby/gists{/gist_id}","starred_url":"https://api.github.com/users/ruby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruby/subscriptions","organizations_url":"https://api.github.com/users/ruby/orgs","repos_url":"https://api.github.com/users/ruby/repos","events_url":"https://api.github.com/users/ruby/events{/privacy}","received_events_url":"https://api.github.com/users/ruby/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ruby/ruby","description":"The Ruby Programming Language","fork":false,"url":"https://api.github.com/repos/ruby/ruby","forks_url":"https://api.github.com/repos/ruby/ruby/forks","keys_url":"https://api.github.com/repos/ruby/ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ruby/ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ruby/ruby/teams","hooks_url":"https://api.github.com/repos/ruby/ruby/hooks","issue_events_url":"https://api.github.com/repos/ruby/ruby/issues/events{/number}","events_url":"https://api.github.com/repos/ruby/ruby/events","assignees_url":"https://api.github.com/repos/ruby/ruby/assignees{/user}","branches_url":"https://api.github.com/repos/ruby/ruby/branches{/branch}","tags_url":"https://api.github.com/repos/ruby/ruby/tags","blobs_url":"https://api.github.com/repos/ruby/ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ruby/ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ruby/ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/ruby/ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ruby/ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/ruby/ruby/languages","stargazers_url":"https://api.github.com/repos/ruby/ruby/stargazers","contributors_url":"https://api.github.com/repos/ruby/ruby/contributors","subscribers_url":"https://api.github.com/repos/ruby/ruby/subscribers","subscription_url":"https://api.github.com/repos/ruby/ruby/subscription","commits_url":"https://api.github.com/repos/ruby/ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/ruby/ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/ruby/ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/ruby/ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/ruby/ruby/contents/{+path}","compare_url":"https://api.github.com/repos/ruby/ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ruby/ruby/merges","archive_url":"https://api.github.com/repos/ruby/ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ruby/ruby/downloads","issues_url":"https://api.github.com/repos/ruby/ruby/issues{/number}","pulls_url":"https://api.github.com/repos/ruby/ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/ruby/ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/ruby/ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ruby/ruby/labels{/name}","releases_url":"https://api.github.com/repos/ruby/ruby/releases{/id}","deployments_url":"https://api.github.com/repos/ruby/ruby/deployments","created_at":"2010-02-27T15:55:23Z","updated_at":"2017-03-13T01:04:44Z","pushed_at":"2017-03-13T06:03:24Z","git_url":"git://github.com/ruby/ruby.git","ssh_url":"git@github.com:ruby/ruby.git","clone_url":"https://github.com/ruby/ruby.git","svn_url":"https://github.com/ruby/ruby","homepage":"http://www.ruby-lang.org/","size":142276,"stargazers_count":11740,"watchers_count":11740,"language":"Ruby","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":3288,"mirror_url":null,"open_issues_count":114,"forks":3288,"open_issues":114,"watchers":11740,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/ruby/ruby/pulls/1537"},"html":{"href":"https://github.com/ruby/ruby/pull/1537"},"issue":{"href":"https://api.github.com/repos/ruby/ruby/issues/1537"},"comments":{"href":"https://api.github.com/repos/ruby/ruby/issues/1537/comments"},"review_comments":{"href":"https://api.github.com/repos/ruby/ruby/pulls/1537/comments"},"review_comment":{"href":"https://api.github.com/repos/ruby/ruby/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ruby/ruby/pulls/1537/commits"},"statuses":{"href":"https://api.github.com/repos/ruby/ruby/statuses/2207b096004ebf85b99641b1c6a9d4bf27a4c3b0"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":0,"deletions":0,"changed_files":0}}
{"actor":{"display_login":"Watson1978"}}