Skip to content

Commit 1b28970

Browse files
committed
Signed-off-by: tison <[email protected]>
1 parent f17cb6a commit 1b28970

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

library/std/src/path.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1571,19 +1571,18 @@ impl PathBuf {
15711571
Some(f) => f.as_encoded_bytes(),
15721572
};
15731573

1574-
let new = extension.as_encoded_bytes();
1574+
let new = extension;
15751575
if !new.is_empty() {
15761576
// truncate until right after the file name
15771577
// this is necessary for trimming the trailing slash
15781578
let end_file_name = file_name[file_name.len()..].as_ptr().addr();
15791579
let start = self.inner.as_encoded_bytes().as_ptr().addr();
1580-
let v = self.as_mut_vec();
1581-
v.truncate(end_file_name.wrapping_sub(start));
1580+
self.inner.truncate(end_file_name.wrapping_sub(start));
15821581

15831582
// append the new extension
1584-
v.reserve_exact(new.len() + 1);
1585-
v.push(b'.');
1586-
v.extend_from_slice(new);
1583+
self.inner.reserve_exact(new.len() + 1);
1584+
self.inner.push(OsStr::new("."));
1585+
self.inner.push(new);
15871586
}
15881587

15891588
true

0 commit comments

Comments
 (0)