{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/7474","repository_url":"https://api.github.com/repos/dart-lang/sdk","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/7474/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/7474/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/7474/events","html_url":"https://github.com/dart-lang/sdk/issues/7474","id":84524176,"number":7474,"title":"dart2js: readability and code size: more flexibility in accessing fields in closure","user":{"login":"rakudrama","id":2108821,"avatar_url":"https://avatars1.githubusercontent.com/u/2108821?v=4","gravatar_id":"","url":"https://api.github.com/users/rakudrama","html_url":"https://github.com/rakudrama","followers_url":"https://api.github.com/users/rakudrama/followers","following_url":"https://api.github.com/users/rakudrama/following{/other_user}","gists_url":"https://api.github.com/users/rakudrama/gists{/gist_id}","starred_url":"https://api.github.com/users/rakudrama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rakudrama/subscriptions","organizations_url":"https://api.github.com/users/rakudrama/orgs","repos_url":"https://api.github.com/users/rakudrama/repos","events_url":"https://api.github.com/users/rakudrama/events{/privacy}","received_events_url":"https://api.github.com/users/rakudrama/received_events","type":"User","site_admin":false},"labels":[{"id":334171875,"url":"https://api.github.com/repos/dart-lang/sdk/labels/P2%20medium","name":"P2 medium","color":"fbca04","default":false},{"id":334529063,"url":"https://api.github.com/repos/dart-lang/sdk/labels/Type:%20bug","name":"Type: bug","color":"ededed","default":false},{"id":219928173,"url":"https://api.github.com/repos/dart-lang/sdk/labels/area-dart2js","name":"area-dart2js","color":"c7def8","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2012-12-18T06:07:10Z","updated_at":"2018-05-03T23:33:34Z","closed_at":"2018-05-03T23:33:34Z","author_association":"MEMBER","body":"This code is a snippet from swarm:\n\n$$._addEventListeners_anon0 = {&quot;&quot;:&quot;Closure;box_0,onCancelWrapper_6,onEndWrapper_7,onLeaveWrapper_8,capture_9&quot;,\n&nbsp;call$1: function(e) {\n&nbsp;&nbsp;var t1, t2, t3, t4;\n&nbsp;&nbsp;t1 = $.document().get$on().get$touchMove();\n&nbsp;&nbsp;t2 = this.box_0;\n&nbsp;&nbsp;t3 = t2.onMove_1;\n&nbsp;&nbsp;t4 = this.capture_9;\n&nbsp;&nbsp;t1.add$2(t3, t4);\n&nbsp;&nbsp;$.document().get$on().get$touchEnd().add$2(this.onEndWrapper_7, t4);\n&nbsp;&nbsp;$.document().get$on().get$touchLeave().add$2(this.onLeaveWrapper_8, t4);\n&nbsp;&nbsp;$.document().get$on().get$touchCancel().add$2(this.onCancelWrapper_6, t4);\n&nbsp;&nbsp;return t2.onStart_0.call$1(e);\n}\n};\n\nThere are several unnecessary temporary variables that can be eliminated by reordering.  The assignments to t2/t3/t4 are safe to be moved by construction.  t1 can be moved past them to avoid a temporary, giving the following:\n\n$$._addEventListeners_anon0 = {&quot;&quot;:&quot;Closure;box_0,onCancelWrapper_6,onEndWrapper_7,onLeaveWrapper_8,capture_9&quot;,\n&nbsp;call$1: function(e) {\n&nbsp;&nbsp;var t2, t4;\n&nbsp;&nbsp;t2 = this.box_0;\n&nbsp;&nbsp;t4 = this.capture_9;\n&nbsp;&nbsp;$.document().get$on().get$touchMove().add$2(t2.onMove_1, t4);\n&nbsp;&nbsp;$.document().get$on().get$touchEnd().add$2(this.onEndWrapper_7, t4);\n&nbsp;&nbsp;$.document().get$on().get$touchLeave().add$2(this.onLeaveWrapper_8, t4);\n&nbsp;&nbsp;$.document().get$on().get$touchCancel().add$2(this.onCancelWrapper_6, t4);\n&nbsp;&nbsp;return t2.onStart_0.call$1(e);\n}\n};\n"},"comment":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/comments/386467435","html_url":"https://github.com/dart-lang/sdk/issues/7474#issuecomment-386467435","issue_url":"https://api.github.com/repos/dart-lang/sdk/issues/7474","id":386467435,"user":{"login":"rakudrama","id":2108821,"avatar_url":"https://avatars1.githubusercontent.com/u/2108821?v=4","gravatar_id":"","url":"https://api.github.com/users/rakudrama","html_url":"https://github.com/rakudrama","followers_url":"https://api.github.com/users/rakudrama/followers","following_url":"https://api.github.com/users/rakudrama/following{/other_user}","gists_url":"https://api.github.com/users/rakudrama/gists{/gist_id}","starred_url":"https://api.github.com/users/rakudrama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rakudrama/subscriptions","organizations_url":"https://api.github.com/users/rakudrama/orgs","repos_url":"https://api.github.com/users/rakudrama/repos","events_url":"https://api.github.com/users/rakudrama/events{/privacy}","received_events_url":"https://api.github.com/users/rakudrama/received_events","type":"User","site_admin":false},"created_at":"2018-05-03T23:33:34Z","updated_at":"2018-05-03T23:33:34Z","author_association":"MEMBER","body":"I think the current code is good enough to close this issue\r\n\r\n```js\r\n    _addEventListeners_closure0: {\r\n      \"^\": \"Closure:0;_box_0,capture,onEndWrapper,onLeaveWrapper,onCancelWrapper\",\r\n      call$1: function(e) {\r\n        var t1, t2, t3;\r\n        t1 = document;\r\n        t2 = this.capture;\r\n        t3 = this._box_0;\r\n        t3.touchMoveSub = W._EventStreamSubscription$(t1, \"touchmove\", t3.onMove, t2);\r\n        t3.touchEndSub = W._EventStreamSubscription$(t1, \"touchend\", this.onEndWrapper, t2);\r\n        t3.touchLeaveSub = W._EventStreamSubscription$(t1, \"touchleave\", this.onLeaveWrapper, t2);\r\n        t3.touchCancelSub = W._EventStreamSubscription$(t1, \"touchcancel\", this.onCancelWrapper, t2);\r\n        return t3.onStart.call$1(e);\r\n      }\r\n    },\r\n```"}}
{"actor":{"display_login":"rakudrama"}}