GitHub PullRequestReviewCommentEvent at 2014-02-05 03:46:11
Repository: rust
Actor: zkamsler
Payload: {"comment":{"url":"https://api.github.com/repos/mozilla/rust/pulls/comments/9449819","id":9449819,"diff_hunk":"@@ -1862,14 +1851,33 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {\n                 // j + 1 could be `len` (for the last `i`), but in\n                 // that case, `i == j` so we don't copy. The\n                 // `.offset(j)` is always in bounds.\n-                ptr::copy_memory(buf_dat.offset(j + 1),\n-                                 buf_dat.offset(j),\n+\n+                let tmp = ptr::read_ptr(read_ptr);\n+                ptr::copy_memory(buf_v.offset(j + 1),\n+                                 buf_v.offset(j),\n                                  i - j as uint);\n-                ptr::copy_nonoverlapping_memory(buf_dat.offset(j), read_ptr, 1);\n+                ptr::copy_nonoverlapping_memory(buf_v.offset(j),\n+                                                ptr::to_unsafe_ptr(&tmp),\n+                                                1);\n+                cast::forget(tmp);\n             }\n         }\n     }\n \n+    if len <= INSERTION {\n+        return;\n+    }\n+\n+    // allocate some memory to use as scratch memory, we keep the\n+    // length 0 so we can keep shallow copies of the contents of `v`\n+    // without risking the dtors running on an object twice if\n+    // `compare` fails.\n+    let mut working_space = with_capacity(2 * len);\n+    // these both are buffers of length `len`.\n+    let mut buf_dat = working_space.as_mut_ptr();","path":"src/libstd/vec.rs","position":72,"original_position":72,"commit_id":"1875332e6d93840c6cdf615521a58db3efb025f6","original_commit_id":"1875332e6d93840c6cdf615521a58db3efb025f6","user":{"login":"zkamsler","id":944662,"avatar_url":"https://gravatar.com/avatar/17e527ea59a862cda5f6eb576218f5a4?d=https%3A%2F%2Fidenticons.github.com%2Fe3fe2fc578c88e5d22a2cc28fbf630b1.png&r=x","gravatar_id":"17e527ea59a862cda5f6eb576218f5a4","url":"https://api.github.com/users/zkamsler","html_url":"https://github.com/zkamsler","followers_url":"https://api.github.com/users/zkamsler/followers","following_url":"https://api.github.com/users/zkamsler/following{/other_user}","gists_url":"https://api.github.com/users/zkamsler/gists{/gist_id}","starred_url":"https://api.github.com/users/zkamsler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zkamsler/subscriptions","organizations_url":"https://api.github.com/users/zkamsler/orgs","repos_url":"https://api.github.com/users/zkamsler/repos","events_url":"https://api.github.com/users/zkamsler/events{/privacy}","received_events_url":"https://api.github.com/users/zkamsler/received_events","type":"User","site_admin":false},"body":"It is read by buf_tmp, but that could be inlined if that is clearer.","created_at":"2014-02-05T03:46:11Z","updated_at":"2014-02-05T03:46:11Z","html_url":"https://github.com/mozilla/rust/pull/12029#discussion_r9449819","pull_request_url":"https://api.github.com/repos/mozilla/rust/pulls/12029","_links":{"self":{"href":"https://api.github.com/repos/mozilla/rust/pulls/comments/9449819"},"html":{"href":"https://github.com/mozilla/rust/pull/12029#discussion_r9449819"},"pull_request":{"href":"https://api.github.com/repos/mozilla/rust/pulls/12029"}}}}