Skip to content

Commit 45e3945

Browse files
committed
all references to PathBuf::as_mut_vec removed for UEFI platforms. Functions remain commented out in case of emergency.
1 parent bd48a20 commit 45e3945

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

library/std/src/ffi/os_str.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,10 @@ impl OsString {
553553
}
554554

555555
/// Part of a hack to make PathBuf::push/pop more efficient.
556-
#[inline]
557-
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
558-
self.inner.as_mut_vec_for_path_buf()
559-
}
556+
//#[inline]
557+
//pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
558+
// self.inner.as_mut_vec_for_path_buf()
559+
//}
560560

561561
/// More well behaving alternative to allowing outer types
562562
/// full mutable access to the core `Vec`.
@@ -565,6 +565,11 @@ impl OsString {
565565
pub(crate) fn truncate(&mut self, len: usize) {
566566
self.inner.truncate(len);
567567
}
568+
569+
#[inline]
570+
pub(crate) fn extend_from_slice(&mut self, other: &[u8]) {
571+
self.inner.extend_from_slice(other);
572+
}
568573
}
569574

570575
#[stable(feature = "rust1", since = "1.0.0")]

library/std/src/path.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1163,10 +1163,10 @@ pub struct PathBuf {
11631163
}
11641164

11651165
impl PathBuf {
1166-
#[inline]
1167-
fn as_mut_vec(&mut self) -> &mut Vec<u8> {
1168-
self.inner.as_mut_vec_for_path_buf()
1169-
}
1166+
//#[inline]
1167+
//fn as_mut_vec(&mut self) -> &mut Vec<u8> {
1168+
// self.inner.as_mut_vec_for_path_buf()
1169+
//}
11701170

11711171
/// Allocates an empty `PathBuf`.
11721172
///
@@ -2645,18 +2645,18 @@ impl Path {
26452645
None => {
26462646
// Enough capacity for the extension and the dot
26472647
let capacity = self_len + extension.len() + 1;
2648-
let whole_path = self_bytes.iter();
2648+
let whole_path = self_bytes;
26492649
(capacity, whole_path)
26502650
}
26512651
Some(previous_extension) => {
26522652
let capacity = self_len + extension.len() - previous_extension.len();
2653-
let path_till_dot = self_bytes[..self_len - previous_extension.len()].iter();
2653+
let path_till_dot = &self_bytes[..self_len - previous_extension.len()];
26542654
(capacity, path_till_dot)
26552655
}
26562656
};
26572657

26582658
let mut new_path = PathBuf::with_capacity(new_capacity);
2659-
new_path.as_mut_vec().extend(slice_to_copy);
2659+
new_path.inner.extend_from_slice(slice_to_copy);
26602660
new_path.set_extension(extension);
26612661
new_path
26622662
}

library/std/src/sys/os_str/bytes.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ impl Buf {
203203
}
204204

205205
/// Part of a hack to make PathBuf::push/pop more efficient.
206-
#[inline]
207-
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
208-
&mut self.inner
209-
}
206+
//#[inline]
207+
//pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
208+
// &mut self.inner
209+
//}
210210

211211
/// More well behaving alternative to allowing outer types
212212
/// full mutable access to the core `Vec`.
@@ -215,6 +215,11 @@ impl Buf {
215215
pub(crate) fn truncate(&mut self, len: usize) {
216216
self.inner.truncate(len);
217217
}
218+
219+
#[inline]
220+
pub(crate) fn extend_from_slice(&mut self, other: &[u8]) {
221+
self.inner.extend_from_slice(other);
222+
}
218223
}
219224

220225
impl Slice {

0 commit comments

Comments
 (0)