{"action":"created","issue":{"url":"https://api.github.com/repos/google/closure-compiler/issues/788","labels_url":"https://api.github.com/repos/google/closure-compiler/issues/788/labels{/name}","comments_url":"https://api.github.com/repos/google/closure-compiler/issues/788/comments","events_url":"https://api.github.com/repos/google/closure-compiler/issues/788/events","html_url":"https://github.com/google/closure-compiler/issues/788","id":55111061,"number":788,"title":"Add smaller optimization for do while loops","user":{"login":"thomasd16","id":9779925,"avatar_url":"https://avatars.githubusercontent.com/u/9779925?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasd16","html_url":"https://github.com/thomasd16","followers_url":"https://api.github.com/users/thomasd16/followers","following_url":"https://api.github.com/users/thomasd16/following{/other_user}","gists_url":"https://api.github.com/users/thomasd16/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasd16/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasd16/subscriptions","organizations_url":"https://api.github.com/users/thomasd16/orgs","repos_url":"https://api.github.com/users/thomasd16/repos","events_url":"https://api.github.com/users/thomasd16/events{/privacy}","received_events_url":"https://api.github.com/users/thomasd16/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/google/closure-compiler/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-22T03:43:13Z","updated_at":"2015-01-22T21:47:51Z","closed_at":null,"body":"If you enter the following under advanced compilation level:\r\n```javascript\r\ndo {\r\n\tsomething(i);\r\n} while (i--);\r\n\r\n//You get the following code:\r\ndo something(i);while(i--);\r\n\r\n//However it would be nice if it would compile down to the following:\r\n while(something(i),i--);\r\n\r\n//This does exactly the same thing while being considerably shorter.\r\n\r\n// You can also do similar compression for regular while loops\r\n// using similar syntax however the savings are much smaller:\r\nwhile (i--) {\r\n\tsomething(i);\r\n}\r\n\r\n//could become\r\nfor(;i--;something());\r\n```\r\nThere may be some reason I missed for why this is not implemented weather or not there are fringe cases in witch it changes what the code does. "},"comment":{"url":"https://api.github.com/repos/google/closure-compiler/issues/comments/71105701","html_url":"https://github.com/google/closure-compiler/issues/788#issuecomment-71105701","issue_url":"https://api.github.com/repos/google/closure-compiler/issues/788","id":71105701,"user":{"login":"thomasd16","id":9779925,"avatar_url":"https://avatars.githubusercontent.com/u/9779925?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasd16","html_url":"https://github.com/thomasd16","followers_url":"https://api.github.com/users/thomasd16/followers","following_url":"https://api.github.com/users/thomasd16/following{/other_user}","gists_url":"https://api.github.com/users/thomasd16/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasd16/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasd16/subscriptions","organizations_url":"https://api.github.com/users/thomasd16/orgs","repos_url":"https://api.github.com/users/thomasd16/repos","events_url":"https://api.github.com/users/thomasd16/events{/privacy}","received_events_url":"https://api.github.com/users/thomasd16/received_events","type":"User","site_admin":false},"created_at":"2015-01-22T21:47:51Z","updated_at":"2015-01-22T21:47:51Z","body":"Actually I did my math wrong for the plain while loops doing `for(;condition;expression);` takes the same space as `for(;condition;)expression;`\r\n\r\n`while(expression,conditiong);` vs `do expression;while(condition);` does save 3 bites. And could be used for any block that boils down to an expression. (No returns, throws, continues, breaks, or nested loops).\r\n\r\nAlso your intuition appears to be correct. I scanned 2 projects for do while loops jQuery and UglifyJS the former had none and the latter only had 3. "}}