Skip to content

Commit

Permalink
remove references to PathBuf::as_mut_vec in PathBuf::_set_extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Borgerr committed Jun 25, 2024
1 parent 37f78f4 commit 7cec6ef
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1511,15 +1511,14 @@ impl PathBuf {
// truncate until right after the file stem
let end_file_stem = file_stem[file_stem.len()..].as_ptr().addr();
let start = self.inner.as_encoded_bytes().as_ptr().addr();
let v = self.as_mut_vec();
v.truncate(end_file_stem.wrapping_sub(start));
self.inner.truncate(end_file_stem.wrapping_sub(start));

// add the new extension, if any
let new = extension.as_encoded_bytes();
let new = extension;
if !new.is_empty() {
v.reserve_exact(new.len() + 1);
v.push(b'.');
v.extend_from_slice(new);
self.inner.reserve_exact(new.len() + 1);
self.inner.push(OsStr::new("."));
self.inner.push(new);
}

true
Expand Down

0 comments on commit 7cec6ef

Please sign in to comment.