{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/25158","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/25158/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/25158/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/25158/events","html_url":"https://github.com/rust-lang/rust/pull/25158","id":73704317,"number":25158,"title":"Add #[inline(always)] to various instances of AsRef::as_ref and AsMut::as_mut","user":{"login":"koute","id":246574,"avatar_url":"https://avatars.githubusercontent.com/u/246574?v=3","gravatar_id":"","url":"https://api.github.com/users/koute","html_url":"https://github.com/koute","followers_url":"https://api.github.com/users/koute/followers","following_url":"https://api.github.com/users/koute/following{/other_user}","gists_url":"https://api.github.com/users/koute/gists{/gist_id}","starred_url":"https://api.github.com/users/koute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koute/subscriptions","organizations_url":"https://api.github.com/users/koute/orgs","repos_url":"https://api.github.com/users/koute/repos","events_url":"https://api.github.com/users/koute/events{/privacy}","received_events_url":"https://api.github.com/users/koute/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"huonw","id":1203825,"avatar_url":"https://avatars.githubusercontent.com/u/1203825?v=3","gravatar_id":"","url":"https://api.github.com/users/huonw","html_url":"https://github.com/huonw","followers_url":"https://api.github.com/users/huonw/followers","following_url":"https://api.github.com/users/huonw/following{/other_user}","gists_url":"https://api.github.com/users/huonw/gists{/gist_id}","starred_url":"https://api.github.com/users/huonw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huonw/subscriptions","organizations_url":"https://api.github.com/users/huonw/orgs","repos_url":"https://api.github.com/users/huonw/repos","events_url":"https://api.github.com/users/huonw/events{/privacy}","received_events_url":"https://api.github.com/users/huonw/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2015-05-06T18:43:40Z","updated_at":"2015-05-07T04:45:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/25158","html_url":"https://github.com/rust-lang/rust/pull/25158","diff_url":"https://github.com/rust-lang/rust/pull/25158.diff","patch_url":"https://github.com/rust-lang/rust/pull/25158.patch"},"body":"I was profiling my code again and this time AsRef<str> for String\r\nwas eating up a considerable chunk of my runtime; adding the inline\r\nannotation made the program run almost twice as fast!\r\n\r\nWhile I was at it I also added the annotation to other implementations\r\nof AsRef as well as AsMut."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/99714986","html_url":"https://github.com/rust-lang/rust/pull/25158#issuecomment-99714986","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/25158","id":99714986,"user":{"login":"koute","id":246574,"avatar_url":"https://avatars.githubusercontent.com/u/246574?v=3","gravatar_id":"","url":"https://api.github.com/users/koute","html_url":"https://github.com/koute","followers_url":"https://api.github.com/users/koute/followers","following_url":"https://api.github.com/users/koute/following{/other_user}","gists_url":"https://api.github.com/users/koute/gists{/gist_id}","starred_url":"https://api.github.com/users/koute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koute/subscriptions","organizations_url":"https://api.github.com/users/koute/orgs","repos_url":"https://api.github.com/users/koute/repos","events_url":"https://api.github.com/users/koute/events{/privacy}","received_events_url":"https://api.github.com/users/koute/received_events","type":"User","site_admin":false},"created_at":"2015-05-07T04:45:12Z","updated_at":"2015-05-07T04:45:12Z","body":"In general I would agree that one should use #[inline] instead, however in this case I can't think of a single case when you wouldn't want those inlined. Since these methods are so tiny a function call is always going to be more expensive *both* time and size wise, and if not inlined you can incur a huge performance hit (as I did) since it will also prevent other optimizations from running.\r\n\r\nNot all of them may be necessary, but I don't think it's a bad idea to mark that we want those always inlined, if only to be explicit about it and consistent."}}