Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7cec6ef

Browse files
committedJun 25, 2024
remove references to PathBuf::as_mut_vec in PathBuf::_set_extension
1 parent 37f78f4 commit 7cec6ef

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed
 

‎std/src/path.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1511,15 +1511,14 @@ impl PathBuf {
15111511
// truncate until right after the file stem
15121512
let end_file_stem = file_stem[file_stem.len()..].as_ptr().addr();
15131513
let start = self.inner.as_encoded_bytes().as_ptr().addr();
1514-
let v = self.as_mut_vec();
1515-
v.truncate(end_file_stem.wrapping_sub(start));
1514+
self.inner.truncate(end_file_stem.wrapping_sub(start));
15161515

15171516
// add the new extension, if any
1518-
let new = extension.as_encoded_bytes();
1517+
let new = extension;
15191518
if !new.is_empty() {
1520-
v.reserve_exact(new.len() + 1);
1521-
v.push(b'.');
1522-
v.extend_from_slice(new);
1519+
self.inner.reserve_exact(new.len() + 1);
1520+
self.inner.push(OsStr::new("."));
1521+
self.inner.push(new);
15231522
}
15241523

15251524
true

0 commit comments

Comments
 (0)
Failed to load comments.