{"action":"created","comment":{"url":"https://api.github.com/repos/google/closure-compiler/pulls/comments/277059610","pull_request_review_id":228780158,"id":277059610,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI3NzA1OTYxMA==","diff_hunk":"@@ -0,0 +1,93 @@\n+/*\n+ * Copyright 2011 The Closure Compiler Authors.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package com.google.javascript.jscomp;\n+\n+import static com.google.common.base.Preconditions.checkState;\n+\n+import com.google.javascript.rhino.IR;\n+import com.google.javascript.rhino.Node;\n+import com.google.javascript.rhino.Token;\n+import com.google.javascript.rhino.jstype.JSType;\n+\n+/**\n+ * A pass that looks for consecutive array.push() calls and combines\n+ * them together.\n+ * \n+ * e.g. array.push(1);array.push(2); is optimized to array.push(1,2);\n+ *\n+ * @author cshung@gmail.com (Andrew Au)\n+ */\n+final class PeepholeCombineArrayPush extends AbstractPeepholeOptimization {\n+\n+  @Override\n+  Node optimizeSubtree(Node subtree) {\n+    if (!subtree.isScript() && !subtree.isBlock()) {\n+      return subtree;\n+    }\n+\n+    boolean codeChanged = false;\n+\n+    for (Node child = subtree.getFirstChild(); child != null; child = child.getNext()) {\n+      if (isArrayDotPush(child)) {","path":"src/com/google/javascript/jscomp/PeepholeCombineArrayPush.java","position":45,"original_position":45,"commit_id":"02f8be465f2b8105f999dcb761786ef4f5fc5b23","original_commit_id":"02f8be465f2b8105f999dcb761786ef4f5fc5b23","user":{"login":"brad4d","id":1115235,"node_id":"MDQ6VXNlcjExMTUyMzU=","avatar_url":"https://avatars1.githubusercontent.com/u/1115235?v=4","gravatar_id":"","url":"https://api.github.com/users/brad4d","html_url":"https://github.com/brad4d","followers_url":"https://api.github.com/users/brad4d/followers","following_url":"https://api.github.com/users/brad4d/following{/other_user}","gists_url":"https://api.github.com/users/brad4d/gists{/gist_id}","starred_url":"https://api.github.com/users/brad4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brad4d/subscriptions","organizations_url":"https://api.github.com/users/brad4d/orgs","repos_url":"https://api.github.com/users/brad4d/repos","events_url":"https://api.github.com/users/brad4d/events{/privacy}","received_events_url":"https://api.github.com/users/brad4d/received_events","type":"User","site_admin":false},"body":"Since `isArrayDotPush()` just returns a boolean, we end up having to re-fetch nodes that we already found in that method. If you instead defined a method that returned an object containing exactly the information you need you could simplify this logic.\r\n\r\n```java\r\nfor (Node statement = subtree.getFirstChild(); statement != null; statement = statement.getNext()) {\r\n  ArrayDotPushStatementSequence arrayDotPushStatement = asArrayDotPushStatementSequence(statement);\r\n  if (arrayDotPushStatementSequence != null) {\r\n    // This always combines following statements into the current one,\r\n    // so statement.getNext() will still move to the new next statement when this is done.\r\n    arrayDotPushStatementSequence.combine();\r\n    codeChanged = true;\r\n  }\r\n}\r\n```\r\n\r\n`asArrayDotPushStatementSequence()` would know how to pull out all the nodes needed for the current statement and any following ones that can be combined and store them in the object it returns.","created_at":"2019-04-19T18:33:41Z","updated_at":"2019-04-19T18:38:17Z","html_url":"https://github.com/google/closure-compiler/pull/3338#discussion_r277059610","pull_request_url":"https://api.github.com/repos/google/closure-compiler/pulls/3338","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/comments/277059610"},"html":{"href":"https://github.com/google/closure-compiler/pull/3338#discussion_r277059610"},"pull_request":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/3338"}}},"pull_request":{"url":"https://api.github.com/repos/google/closure-compiler/pulls/3338","id":271570798,"node_id":"MDExOlB1bGxSZXF1ZXN0MjcxNTcwNzk4","html_url":"https://github.com/google/closure-compiler/pull/3338","diff_url":"https://github.com/google/closure-compiler/pull/3338.diff","patch_url":"https://github.com/google/closure-compiler/pull/3338.patch","issue_url":"https://api.github.com/repos/google/closure-compiler/issues/3338","number":3338,"state":"open","locked":false,"title":"Introducing PeepholeCombineArrayPush","user":{"login":"cshung","id":3410332,"node_id":"MDQ6VXNlcjM0MTAzMzI=","avatar_url":"https://avatars0.githubusercontent.com/u/3410332?v=4","gravatar_id":"","url":"https://api.github.com/users/cshung","html_url":"https://github.com/cshung","followers_url":"https://api.github.com/users/cshung/followers","following_url":"https://api.github.com/users/cshung/following{/other_user}","gists_url":"https://api.github.com/users/cshung/gists{/gist_id}","starred_url":"https://api.github.com/users/cshung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cshung/subscriptions","organizations_url":"https://api.github.com/users/cshung/orgs","repos_url":"https://api.github.com/users/cshung/repos","events_url":"https://api.github.com/users/cshung/events{/privacy}","received_events_url":"https://api.github.com/users/cshung/received_events","type":"User","site_admin":false},"body":"Fixes issue #3212 ","created_at":"2019-04-18T06:56:13Z","updated_at":"2019-04-19T18:38:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dbf4b3c8934a7b8cf5f1c42767abd5858c49dd4d","assignee":{"login":"brad4d","id":1115235,"node_id":"MDQ6VXNlcjExMTUyMzU=","avatar_url":"https://avatars1.githubusercontent.com/u/1115235?v=4","gravatar_id":"","url":"https://api.github.com/users/brad4d","html_url":"https://github.com/brad4d","followers_url":"https://api.github.com/users/brad4d/followers","following_url":"https://api.github.com/users/brad4d/following{/other_user}","gists_url":"https://api.github.com/users/brad4d/gists{/gist_id}","starred_url":"https://api.github.com/users/brad4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brad4d/subscriptions","organizations_url":"https://api.github.com/users/brad4d/orgs","repos_url":"https://api.github.com/users/brad4d/repos","events_url":"https://api.github.com/users/brad4d/events{/privacy}","received_events_url":"https://api.github.com/users/brad4d/received_events","type":"User","site_admin":false},"assignees":[{"login":"brad4d","id":1115235,"node_id":"MDQ6VXNlcjExMTUyMzU=","avatar_url":"https://avatars1.githubusercontent.com/u/1115235?v=4","gravatar_id":"","url":"https://api.github.com/users/brad4d","html_url":"https://github.com/brad4d","followers_url":"https://api.github.com/users/brad4d/followers","following_url":"https://api.github.com/users/brad4d/following{/other_user}","gists_url":"https://api.github.com/users/brad4d/gists{/gist_id}","starred_url":"https://api.github.com/users/brad4d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brad4d/subscriptions","organizations_url":"https://api.github.com/users/brad4d/orgs","repos_url":"https://api.github.com/users/brad4d/repos","events_url":"https://api.github.com/users/brad4d/events{/privacy}","received_events_url":"https://api.github.com/users/brad4d/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":147878228,"node_id":"MDU6TGFiZWwxNDc4NzgyMjg=","url":"https://api.github.com/repos/google/closure-compiler/labels/cla:%20yes","name":"cla: yes","color":"009800","default":false},{"id":1167227914,"node_id":"MDU6TGFiZWwxMTY3MjI3OTE0","url":"https://api.github.com/repos/google/closure-compiler/labels/internal-issue-created","name":"internal-issue-created","color":"6e6bc4","default":false},{"id":1129371827,"node_id":"MDU6TGFiZWwxMTI5MzcxODI3","url":"https://api.github.com/repos/google/closure-compiler/labels/triage-done","name":"triage-done","color":"098c4f","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/google/closure-compiler/pulls/3338/commits","review_comments_url":"https://api.github.com/repos/google/closure-compiler/pulls/3338/comments","review_comment_url":"https://api.github.com/repos/google/closure-compiler/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/closure-compiler/issues/3338/comments","statuses_url":"https://api.github.com/repos/google/closure-compiler/statuses/02f8be465f2b8105f999dcb761786ef4f5fc5b23","head":{"label":"cshung:dev/andrewau/PeepholeCombineArrayPush","ref":"dev/andrewau/PeepholeCombineArrayPush","sha":"02f8be465f2b8105f999dcb761786ef4f5fc5b23","user":{"login":"cshung","id":3410332,"node_id":"MDQ6VXNlcjM0MTAzMzI=","avatar_url":"https://avatars0.githubusercontent.com/u/3410332?v=4","gravatar_id":"","url":"https://api.github.com/users/cshung","html_url":"https://github.com/cshung","followers_url":"https://api.github.com/users/cshung/followers","following_url":"https://api.github.com/users/cshung/following{/other_user}","gists_url":"https://api.github.com/users/cshung/gists{/gist_id}","starred_url":"https://api.github.com/users/cshung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cshung/subscriptions","organizations_url":"https://api.github.com/users/cshung/orgs","repos_url":"https://api.github.com/users/cshung/repos","events_url":"https://api.github.com/users/cshung/events{/privacy}","received_events_url":"https://api.github.com/users/cshung/received_events","type":"User","site_admin":false},"repo":{"id":175038009,"node_id":"MDEwOlJlcG9zaXRvcnkxNzUwMzgwMDk=","name":"closure-compiler","full_name":"cshung/closure-compiler","private":false,"owner":{"login":"cshung","id":3410332,"node_id":"MDQ6VXNlcjM0MTAzMzI=","avatar_url":"https://avatars0.githubusercontent.com/u/3410332?v=4","gravatar_id":"","url":"https://api.github.com/users/cshung","html_url":"https://github.com/cshung","followers_url":"https://api.github.com/users/cshung/followers","following_url":"https://api.github.com/users/cshung/following{/other_user}","gists_url":"https://api.github.com/users/cshung/gists{/gist_id}","starred_url":"https://api.github.com/users/cshung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cshung/subscriptions","organizations_url":"https://api.github.com/users/cshung/orgs","repos_url":"https://api.github.com/users/cshung/repos","events_url":"https://api.github.com/users/cshung/events{/privacy}","received_events_url":"https://api.github.com/users/cshung/received_events","type":"User","site_admin":false},"html_url":"https://github.com/cshung/closure-compiler","description":"A JavaScript checker and optimizer.","fork":true,"url":"https://api.github.com/repos/cshung/closure-compiler","forks_url":"https://api.github.com/repos/cshung/closure-compiler/forks","keys_url":"https://api.github.com/repos/cshung/closure-compiler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cshung/closure-compiler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cshung/closure-compiler/teams","hooks_url":"https://api.github.com/repos/cshung/closure-compiler/hooks","issue_events_url":"https://api.github.com/repos/cshung/closure-compiler/issues/events{/number}","events_url":"https://api.github.com/repos/cshung/closure-compiler/events","assignees_url":"https://api.github.com/repos/cshung/closure-compiler/assignees{/user}","branches_url":"https://api.github.com/repos/cshung/closure-compiler/branches{/branch}","tags_url":"https://api.github.com/repos/cshung/closure-compiler/tags","blobs_url":"https://api.github.com/repos/cshung/closure-compiler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cshung/closure-compiler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cshung/closure-compiler/git/refs{/sha}","trees_url":"https://api.github.com/repos/cshung/closure-compiler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cshung/closure-compiler/statuses/{sha}","languages_url":"https://api.github.com/repos/cshung/closure-compiler/languages","stargazers_url":"https://api.github.com/repos/cshung/closure-compiler/stargazers","contributors_url":"https://api.github.com/repos/cshung/closure-compiler/contributors","subscribers_url":"https://api.github.com/repos/cshung/closure-compiler/subscribers","subscription_url":"https://api.github.com/repos/cshung/closure-compiler/subscription","commits_url":"https://api.github.com/repos/cshung/closure-compiler/commits{/sha}","git_commits_url":"https://api.github.com/repos/cshung/closure-compiler/git/commits{/sha}","comments_url":"https://api.github.com/repos/cshung/closure-compiler/comments{/number}","issue_comment_url":"https://api.github.com/repos/cshung/closure-compiler/issues/comments{/number}","contents_url":"https://api.github.com/repos/cshung/closure-compiler/contents/{+path}","compare_url":"https://api.github.com/repos/cshung/closure-compiler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cshung/closure-compiler/merges","archive_url":"https://api.github.com/repos/cshung/closure-compiler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cshung/closure-compiler/downloads","issues_url":"https://api.github.com/repos/cshung/closure-compiler/issues{/number}","pulls_url":"https://api.github.com/repos/cshung/closure-compiler/pulls{/number}","milestones_url":"https://api.github.com/repos/cshung/closure-compiler/milestones{/number}","notifications_url":"https://api.github.com/repos/cshung/closure-compiler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cshung/closure-compiler/labels{/name}","releases_url":"https://api.github.com/repos/cshung/closure-compiler/releases{/id}","deployments_url":"https://api.github.com/repos/cshung/closure-compiler/deployments","created_at":"2019-03-11T16:13:27Z","updated_at":"2019-04-18T06:51:47Z","pushed_at":"2019-04-19T05:23:35Z","git_url":"git://github.com/cshung/closure-compiler.git","ssh_url":"git@github.com:cshung/closure-compiler.git","clone_url":"https://github.com/cshung/closure-compiler.git","svn_url":"https://github.com/cshung/closure-compiler","homepage":"https://developers.google.com/closure/compiler/","size":143621,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"191f292b824eb82f49f5d076aa36eebbecf6458f","user":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":18845024,"node_id":"MDEwOlJlcG9zaXRvcnkxODg0NTAyNA==","name":"closure-compiler","full_name":"google/closure-compiler","private":false,"owner":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/google/closure-compiler","description":"A JavaScript checker and optimizer.","fork":false,"url":"https://api.github.com/repos/google/closure-compiler","forks_url":"https://api.github.com/repos/google/closure-compiler/forks","keys_url":"https://api.github.com/repos/google/closure-compiler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/closure-compiler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/closure-compiler/teams","hooks_url":"https://api.github.com/repos/google/closure-compiler/hooks","issue_events_url":"https://api.github.com/repos/google/closure-compiler/issues/events{/number}","events_url":"https://api.github.com/repos/google/closure-compiler/events","assignees_url":"https://api.github.com/repos/google/closure-compiler/assignees{/user}","branches_url":"https://api.github.com/repos/google/closure-compiler/branches{/branch}","tags_url":"https://api.github.com/repos/google/closure-compiler/tags","blobs_url":"https://api.github.com/repos/google/closure-compiler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/closure-compiler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/closure-compiler/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/closure-compiler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/closure-compiler/statuses/{sha}","languages_url":"https://api.github.com/repos/google/closure-compiler/languages","stargazers_url":"https://api.github.com/repos/google/closure-compiler/stargazers","contributors_url":"https://api.github.com/repos/google/closure-compiler/contributors","subscribers_url":"https://api.github.com/repos/google/closure-compiler/subscribers","subscription_url":"https://api.github.com/repos/google/closure-compiler/subscription","commits_url":"https://api.github.com/repos/google/closure-compiler/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/closure-compiler/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/closure-compiler/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/closure-compiler/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/closure-compiler/contents/{+path}","compare_url":"https://api.github.com/repos/google/closure-compiler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/closure-compiler/merges","archive_url":"https://api.github.com/repos/google/closure-compiler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/closure-compiler/downloads","issues_url":"https://api.github.com/repos/google/closure-compiler/issues{/number}","pulls_url":"https://api.github.com/repos/google/closure-compiler/pulls{/number}","milestones_url":"https://api.github.com/repos/google/closure-compiler/milestones{/number}","notifications_url":"https://api.github.com/repos/google/closure-compiler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/closure-compiler/labels{/name}","releases_url":"https://api.github.com/repos/google/closure-compiler/releases{/id}","deployments_url":"https://api.github.com/repos/google/closure-compiler/deployments","created_at":"2014-04-16T15:30:36Z","updated_at":"2019-04-19T17:35:41Z","pushed_at":"2019-04-19T17:35:28Z","git_url":"git://github.com/google/closure-compiler.git","ssh_url":"git@github.com:google/closure-compiler.git","clone_url":"https://github.com/google/closure-compiler.git","svn_url":"https://github.com/google/closure-compiler","homepage":"https://developers.google.com/closure/compiler/","size":149595,"stargazers_count":4854,"watchers_count":4854,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":893,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":797,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":893,"open_issues":797,"watchers":4854,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/3338"},"html":{"href":"https://github.com/google/closure-compiler/pull/3338"},"issue":{"href":"https://api.github.com/repos/google/closure-compiler/issues/3338"},"comments":{"href":"https://api.github.com/repos/google/closure-compiler/issues/3338/comments"},"review_comments":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/3338/comments"},"review_comment":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/closure-compiler/pulls/3338/commits"},"statuses":{"href":"https://api.github.com/repos/google/closure-compiler/statuses/02f8be465f2b8105f999dcb761786ef4f5fc5b23"}},"author_association":"NONE"}}
{"actor":{"display_login":"brad4d"}}