diff options
| author | Ralf Jung <post@ralfj.de> | 2024-04-26 17:55:10 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-04-26 18:09:09 +0200 |
| commit | c47978a241ac1dd512b2ed7d146c1e1a71326dec (patch) | |
| tree | 758a75d2684f9848c9078fbdefc9f2ae71e0f8c8 /library/std/src/sys | |
| parent | 5ff8fbb2d83d423974d21d754b5ee56a4c869551 (diff) | |
| download | rust-c47978a241ac1dd512b2ed7d146c1e1a71326dec.tar.gz rust-c47978a241ac1dd512b2ed7d146c1e1a71326dec.zip | |
PathBuf: replace transmuting by accessor functions
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/os_str/bytes.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sys/os_str/wtf8.rs | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/library/std/src/sys/os_str/bytes.rs b/library/std/src/sys/os_str/bytes.rs index 4ca3f1cd185..3076e18b237 100644 --- a/library/std/src/sys/os_str/bytes.rs +++ b/library/std/src/sys/os_str/bytes.rs @@ -198,6 +198,12 @@ impl Buf { pub fn into_rc(&self) -> Rc<Slice> { self.as_slice().into_rc() } + + /// Part of a hack to make PathBuf::push/pop more efficient. + #[inline] + pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> { + &mut self.inner + } } impl Slice { diff --git a/library/std/src/sys/os_str/wtf8.rs b/library/std/src/sys/os_str/wtf8.rs index 352bd735903..b3ceb55802d 100644 --- a/library/std/src/sys/os_str/wtf8.rs +++ b/library/std/src/sys/os_str/wtf8.rs @@ -158,6 +158,12 @@ impl Buf { pub fn into_rc(&self) -> Rc<Slice> { self.as_slice().into_rc() } + + /// Part of a hack to make PathBuf::push/pop more efficient. + #[inline] + pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> { + self.inner.as_mut_vec_for_path_buf() + } } impl Slice { |
