{"action":"created","issue":{"url":"https://api.github.com/repos/babel/babel/issues/1845","labels_url":"https://api.github.com/repos/babel/babel/issues/1845/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/1845/comments","events_url":"https://api.github.com/repos/babel/babel/issues/1845/events","html_url":"https://github.com/babel/babel/issues/1845","id":91216958,"number":1845,"title":"Investigate performance of rest parameter indice optimisation ","user":{"login":"sebmck","id":853712,"avatar_url":"https://avatars.githubusercontent.com/u/853712?v=3","gravatar_id":"","url":"https://api.github.com/users/sebmck","html_url":"https://github.com/sebmck","followers_url":"https://api.github.com/users/sebmck/followers","following_url":"https://api.github.com/users/sebmck/following{/other_user}","gists_url":"https://api.github.com/users/sebmck/gists{/gist_id}","starred_url":"https://api.github.com/users/sebmck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebmck/subscriptions","organizations_url":"https://api.github.com/users/sebmck/orgs","repos_url":"https://api.github.com/users/sebmck/repos","events_url":"https://api.github.com/users/sebmck/events{/privacy}","received_events_url":"https://api.github.com/users/sebmck/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-06-26T10:26:49Z","updated_at":"2015-06-26T20:16:06Z","closed_at":"2015-06-26T11:13:32Z","body":"The `arguments` rest parameter optimisation is actually a deoptimisation.\r\n\r\n```javascript\r\nfunction fetch() {\r\n  return arguments[1];\r\n}\r\n```\r\n\r\nis slower than\r\n\r\n```javascript\r\nfunction allocate() {\r\n  for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\r\n    args[_key - 1] = arguments[_key];\r\n  }\r\n\r\n  return args[0];\r\n}\r\n```\r\n\r\nBenchmark:\r\n\r\n```javascript\r\nvar Benchmark = require(\"benchmark\");\r\nvar suite = new Benchmark.Suite;\r\n\r\nfunction fetch() {\r\n  return arguments[1];\r\n}\r\n\r\nfunction allocate() {\r\n  for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\r\n    args[_key - 1] = arguments[_key];\r\n  }\r\n\r\n  return args[0];\r\n}\r\n\r\nsuite.add(\"allocate\", function() {\r\n  allocate();\r\n});\r\n\r\nsuite.add(\"fetch\", function() {\r\n  fetch();\r\n});\r\n\r\nsuite.on(\"cycle\", function(event) {\r\n  console.log(String(event.target));\r\n})\r\n\r\nsuite.run();\r\n```\r\n\r\ncc @stefanpenner @benjamingr"},"comment":{"url":"https://api.github.com/repos/babel/babel/issues/comments/115866936","html_url":"https://github.com/babel/babel/issues/1845#issuecomment-115866936","issue_url":"https://api.github.com/repos/babel/babel/issues/1845","id":115866936,"user":{"login":"stefanpenner","id":1377,"avatar_url":"https://avatars.githubusercontent.com/u/1377?v=3","gravatar_id":"","url":"https://api.github.com/users/stefanpenner","html_url":"https://github.com/stefanpenner","followers_url":"https://api.github.com/users/stefanpenner/followers","following_url":"https://api.github.com/users/stefanpenner/following{/other_user}","gists_url":"https://api.github.com/users/stefanpenner/gists{/gist_id}","starred_url":"https://api.github.com/users/stefanpenner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefanpenner/subscriptions","organizations_url":"https://api.github.com/users/stefanpenner/orgs","repos_url":"https://api.github.com/users/stefanpenner/repos","events_url":"https://api.github.com/users/stefanpenner/events{/privacy}","received_events_url":"https://api.github.com/users/stefanpenner/received_events","type":"User","site_admin":false},"created_at":"2015-06-26T20:16:06Z","updated_at":"2015-06-26T20:16:06Z","body":"its also worth noting that function body size, does affect inlining potential. Which can hurt other things, we just need to be careful at looking at the whole picture, not just in isolation. \r\n\r\nsilly perf :P"}}