{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/51601","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/51601/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/51601/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/51601/events","html_url":"https://github.com/rust-lang/rust/pull/51601","id":333015455,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1MzQ5Mjcx","number":51601,"title":"Specialize StepBy<Range(Inclusive)>","user":{"login":"Emerentius","id":9992929,"node_id":"MDQ6VXNlcjk5OTI5Mjk=","avatar_url":"https://avatars3.githubusercontent.com/u/9992929?v=4","gravatar_id":"","url":"https://api.github.com/users/Emerentius","html_url":"https://github.com/Emerentius","followers_url":"https://api.github.com/users/Emerentius/followers","following_url":"https://api.github.com/users/Emerentius/following{/other_user}","gists_url":"https://api.github.com/users/Emerentius/gists{/gist_id}","starred_url":"https://api.github.com/users/Emerentius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Emerentius/subscriptions","organizations_url":"https://api.github.com/users/Emerentius/orgs","repos_url":"https://api.github.com/users/Emerentius/repos","events_url":"https://api.github.com/users/Emerentius/events{/privacy}","received_events_url":"https://api.github.com/users/Emerentius/received_events","type":"User","site_admin":false},"labels":[{"id":583437191,"node_id":"MDU6TGFiZWw1ODM0MzcxOTE=","url":"https://api.github.com/repos/rust-lang/rust/labels/S-waiting-on-bors","name":"S-waiting-on-bors","color":"d3dddd","default":false}],"state":"closed","locked":false,"assignee":{"login":"sfackler","id":1455697,"node_id":"MDQ6VXNlcjE0NTU2OTc=","avatar_url":"https://avatars0.githubusercontent.com/u/1455697?v=4","gravatar_id":"","url":"https://api.github.com/users/sfackler","html_url":"https://github.com/sfackler","followers_url":"https://api.github.com/users/sfackler/followers","following_url":"https://api.github.com/users/sfackler/following{/other_user}","gists_url":"https://api.github.com/users/sfackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sfackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfackler/subscriptions","organizations_url":"https://api.github.com/users/sfackler/orgs","repos_url":"https://api.github.com/users/sfackler/repos","events_url":"https://api.github.com/users/sfackler/events{/privacy}","received_events_url":"https://api.github.com/users/sfackler/received_events","type":"User","site_admin":false},"assignees":[{"login":"sfackler","id":1455697,"node_id":"MDQ6VXNlcjE0NTU2OTc=","avatar_url":"https://avatars0.githubusercontent.com/u/1455697?v=4","gravatar_id":"","url":"https://api.github.com/users/sfackler","html_url":"https://github.com/sfackler","followers_url":"https://api.github.com/users/sfackler/followers","following_url":"https://api.github.com/users/sfackler/following{/other_user}","gists_url":"https://api.github.com/users/sfackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sfackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfackler/subscriptions","organizations_url":"https://api.github.com/users/sfackler/orgs","repos_url":"https://api.github.com/users/sfackler/repos","events_url":"https://api.github.com/users/sfackler/events{/privacy}","received_events_url":"https://api.github.com/users/sfackler/received_events","type":"User","site_admin":false}],"milestone":null,"comments":13,"created_at":"2018-06-16T21:13:01Z","updated_at":"2018-11-15T16:29:03Z","closed_at":"2018-06-21T11:09:45Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/51601","html_url":"https://github.com/rust-lang/rust/pull/51601","diff_url":"https://github.com/rust-lang/rust/pull/51601.diff","patch_url":"https://github.com/rust-lang/rust/pull/51601.patch"},"body":"Part of #51557, related to #43064, #31155\r\n\r\nAs discussed in the above issues, `step_by` optimizes very badly on ranges which is related to\r\n1. the special casing of the first `StepBy::next()` call\r\n2. the need to do 2 additions of `n - 1` and `1` inside the range's `next()`\r\n\r\nThis PR eliminates both by overriding `next()` to always produce the current element and also step ahead by `n` elements in one go. The generated code is much better, even identical in the case of a `Range` with constant `start` and `end` where `start+step` can't overflow. Without constant bounds it's a bit longer than the manual loop. `RangeInclusive` doesn't optimize as nicely but is still much better than the original asm.\r\nUnsigned integers optimize better than signed ones for some reason.\r\n\r\nSee the following two links for a comparison.\r\n\r\n[godbolt: specialization for ..](https://godbolt.org/g/haHLJr)\r\n[godbolt: specialization for ..=](https://godbolt.org/g/ewyMu6)\r\n\r\n`RangeFrom`, the only other range with an `Iterator` implementation can't be specialized like this without changing behaviour due to overflow. There is no way to save \"finished-ness\".\r\n\r\nThe approach can not be used in general, because it would produce side effects of the underlying iterator too early. \r\n\r\nMay obsolete #51435, haven't checked."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/439101749","html_url":"https://github.com/rust-lang/rust/pull/51601#issuecomment-439101749","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/51601","id":439101749,"node_id":"MDEyOklzc3VlQ29tbWVudDQzOTEwMTc0OQ==","user":{"login":"jethrogb","id":1132307,"node_id":"MDQ6VXNlcjExMzIzMDc=","avatar_url":"https://avatars0.githubusercontent.com/u/1132307?v=4","gravatar_id":"","url":"https://api.github.com/users/jethrogb","html_url":"https://github.com/jethrogb","followers_url":"https://api.github.com/users/jethrogb/followers","following_url":"https://api.github.com/users/jethrogb/following{/other_user}","gists_url":"https://api.github.com/users/jethrogb/gists{/gist_id}","starred_url":"https://api.github.com/users/jethrogb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jethrogb/subscriptions","organizations_url":"https://api.github.com/users/jethrogb/orgs","repos_url":"https://api.github.com/users/jethrogb/repos","events_url":"https://api.github.com/users/jethrogb/events{/privacy}","received_events_url":"https://api.github.com/users/jethrogb/received_events","type":"User","site_admin":false},"created_at":"2018-11-15T16:29:03Z","updated_at":"2018-11-15T16:29:03Z","author_association":"CONTRIBUTOR","body":"This is buggy: https://github.com/rust-lang/rust/issues/55985"}}
{"actor":{"display_login":"jethrogb"}}