{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/47941856","id":47941856,"diff_hunk":"@@ -0,0 +1,339 @@\n+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT\n+// file at the top-level directory of this distribution and at\n+// http://rust-lang.org/COPYRIGHT.\n+//\n+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or\n+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license\n+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your\n+// option. This file may not be copied, modified, or distributed\n+// except according to those terms.\n+//\n+// Original implementation taken from rust-memchr\n+// Copyright 2015 Andrew Gallant, bluss and Nicolas Koch\n+\n+\n+use libc::c_void;\n+use libc::{c_int, size_t};\n+\n+\n+/// A safe interface to `memchr`.\n+///\n+/// Returns the index corresponding to the first occurrence of `needle` in\n+/// `haystack`, or `None` if one is not found.\n+///\n+/// memchr reduces to super-optimized machine code at around an order of\n+/// magnitude faster than `haystack.iter().position(|&b| b == needle)`.\n+/// (See benchmarks.)\n+///\n+/// # Example\n+///\n+/// This shows how to find the first position of a byte in a byte string.\n+///\n+/// ```rust\n+/// use memchr::memchr;\n+///\n+/// let haystack = b\"the quick brown fox\";\n+/// assert_eq!(memchr(b'k', haystack), Some(8));\n+/// ```\n+pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {\n+    // libc memchr\n+    #[cfg(any(not(target_os = \"windows\"),\n+              not(any(target_pointer_width = \"32\",\n+                      target_pointer_width = \"64\"))))]","path":"src/libstd/memchr.rs","position":40,"original_position":42,"commit_id":"7aff040cbe01cd150a51e3daa9df7a8f7af291e1","original_commit_id":"2ab30fff00e9c8f122b53a17ddc736dba1ded7ec","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"body":"(ping on removing these cfgs)","created_at":"2015-12-17T18:29:35Z","updated_at":"2015-12-17T18:29:35Z","html_url":"https://github.com/rust-lang/rust/pull/30381#discussion_r47941856","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/30381","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/47941856"},"html":{"href":"https://github.com/rust-lang/rust/pull/30381#discussion_r47941856"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/30381"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/30381","id":53640225,"html_url":"https://github.com/rust-lang/rust/pull/30381","diff_url":"https://github.com/rust-lang/rust/pull/30381.diff","patch_url":"https://github.com/rust-lang/rust/pull/30381.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/30381","number":30381,"state":"open","locked":false,"title":"Memchr in std","user":{"login":"fhahn","id":450489,"avatar_url":"https://avatars.githubusercontent.com/u/450489?v=3","gravatar_id":"","url":"https://api.github.com/users/fhahn","html_url":"https://github.com/fhahn","followers_url":"https://api.github.com/users/fhahn/followers","following_url":"https://api.github.com/users/fhahn/following{/other_user}","gists_url":"https://api.github.com/users/fhahn/gists{/gist_id}","starred_url":"https://api.github.com/users/fhahn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhahn/subscriptions","organizations_url":"https://api.github.com/users/fhahn/orgs","repos_url":"https://api.github.com/users/fhahn/repos","events_url":"https://api.github.com/users/fhahn/events{/privacy}","received_events_url":"https://api.github.com/users/fhahn/received_events","type":"User","site_admin":false},"body":"This PR adds `memchr`and `memrchr` based on @BurntSushi 's rust-memchr crate to libstd (as discussed in #30151).\r\n\r\nI've update some places in libstd to use memchr/memrchr, but I am not sure if there are other places where it could be used as well.\r\n\r\nref #30076","created_at":"2015-12-14T23:47:39Z","updated_at":"2015-12-17T18:29:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a673a1bb88d7b488ff46c706a57723748e72abe1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/30381/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/30381/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/30381/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/7aff040cbe01cd150a51e3daa9df7a8f7af291e1","head":{"label":"fhahn:memchr-in-std","ref":"memchr-in-std","sha":"7aff040cbe01cd150a51e3daa9df7a8f7af291e1","user":{"login":"fhahn","id":450489,"avatar_url":"https://avatars.githubusercontent.com/u/450489?v=3","gravatar_id":"","url":"https://api.github.com/users/fhahn","html_url":"https://github.com/fhahn","followers_url":"https://api.github.com/users/fhahn/followers","following_url":"https://api.github.com/users/fhahn/following{/other_user}","gists_url":"https://api.github.com/users/fhahn/gists{/gist_id}","starred_url":"https://api.github.com/users/fhahn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhahn/subscriptions","organizations_url":"https://api.github.com/users/fhahn/orgs","repos_url":"https://api.github.com/users/fhahn/repos","events_url":"https://api.github.com/users/fhahn/events{/privacy}","received_events_url":"https://api.github.com/users/fhahn/received_events","type":"User","site_admin":false},"repo":{"id":12282405,"name":"rust","full_name":"fhahn/rust","owner":{"login":"fhahn","id":450489,"avatar_url":"https://avatars.githubusercontent.com/u/450489?v=3","gravatar_id":"","url":"https://api.github.com/users/fhahn","html_url":"https://github.com/fhahn","followers_url":"https://api.github.com/users/fhahn/followers","following_url":"https://api.github.com/users/fhahn/following{/other_user}","gists_url":"https://api.github.com/users/fhahn/gists{/gist_id}","starred_url":"https://api.github.com/users/fhahn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhahn/subscriptions","organizations_url":"https://api.github.com/users/fhahn/orgs","repos_url":"https://api.github.com/users/fhahn/repos","events_url":"https://api.github.com/users/fhahn/events{/privacy}","received_events_url":"https://api.github.com/users/fhahn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fhahn/rust","description":"a safe, concurrent, practical language","fork":true,"url":"https://api.github.com/repos/fhahn/rust","forks_url":"https://api.github.com/repos/fhahn/rust/forks","keys_url":"https://api.github.com/repos/fhahn/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fhahn/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fhahn/rust/teams","hooks_url":"https://api.github.com/repos/fhahn/rust/hooks","issue_events_url":"https://api.github.com/repos/fhahn/rust/issues/events{/number}","events_url":"https://api.github.com/repos/fhahn/rust/events","assignees_url":"https://api.github.com/repos/fhahn/rust/assignees{/user}","branches_url":"https://api.github.com/repos/fhahn/rust/branches{/branch}","tags_url":"https://api.github.com/repos/fhahn/rust/tags","blobs_url":"https://api.github.com/repos/fhahn/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fhahn/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fhahn/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/fhahn/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fhahn/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/fhahn/rust/languages","stargazers_url":"https://api.github.com/repos/fhahn/rust/stargazers","contributors_url":"https://api.github.com/repos/fhahn/rust/contributors","subscribers_url":"https://api.github.com/repos/fhahn/rust/subscribers","subscription_url":"https://api.github.com/repos/fhahn/rust/subscription","commits_url":"https://api.github.com/repos/fhahn/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/fhahn/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/fhahn/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/fhahn/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/fhahn/rust/contents/{+path}","compare_url":"https://api.github.com/repos/fhahn/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fhahn/rust/merges","archive_url":"https://api.github.com/repos/fhahn/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fhahn/rust/downloads","issues_url":"https://api.github.com/repos/fhahn/rust/issues{/number}","pulls_url":"https://api.github.com/repos/fhahn/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/fhahn/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/fhahn/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fhahn/rust/labels{/name}","releases_url":"https://api.github.com/repos/fhahn/rust/releases{/id}","created_at":"2013-08-21T21:50:21Z","updated_at":"2015-04-23T13:36:41Z","pushed_at":"2015-12-16T23:48:57Z","git_url":"git://github.com/fhahn/rust.git","ssh_url":"git@github.com:fhahn/rust.git","clone_url":"https://github.com/fhahn/rust.git","svn_url":"https://github.com/fhahn/rust","homepage":"http://www.rust-lang.org","size":333410,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"38da1a406472cf3c675c70fe2c0b1c665fce4b16","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":724712,"name":"rust","full_name":"rust-lang/rust","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/rust","description":"A safe, concurrent, practical language.","fork":false,"url":"https://api.github.com/repos/rust-lang/rust","forks_url":"https://api.github.com/repos/rust-lang/rust/forks","keys_url":"https://api.github.com/repos/rust-lang/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rust/teams","hooks_url":"https://api.github.com/repos/rust-lang/rust/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rust/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rust/events","assignees_url":"https://api.github.com/repos/rust-lang/rust/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rust/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rust/tags","blobs_url":"https://api.github.com/repos/rust-lang/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rust/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rust/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rust/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rust/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rust/subscription","commits_url":"https://api.github.com/repos/rust-lang/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/rust/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rust/merges","archive_url":"https://api.github.com/repos/rust-lang/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rust/downloads","issues_url":"https://api.github.com/repos/rust-lang/rust/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rust/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rust/releases{/id}","created_at":"2010-06-16T20:39:03Z","updated_at":"2015-12-17T14:43:45Z","pushed_at":"2015-12-17T18:26:37Z","git_url":"git://github.com/rust-lang/rust.git","ssh_url":"git@github.com:rust-lang/rust.git","clone_url":"https://github.com/rust-lang/rust.git","svn_url":"https://github.com/rust-lang/rust","homepage":"http://www.rust-lang.org","size":393391,"stargazers_count":14599,"watchers_count":14599,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2850,"mirror_url":null,"open_issues_count":2381,"forks":2850,"open_issues":2381,"watchers":14599,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/30381"},"html":{"href":"https://github.com/rust-lang/rust/pull/30381"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/30381"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/30381/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/30381/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/30381/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/7aff040cbe01cd150a51e3daa9df7a8f7af291e1"}}}}