Skip to content

Commit fe2d661

Browse files
committed
Simplify code for handling Redox paths
1 parent ab48de8 commit fe2d661

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/libstd/path.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,7 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr {
324324
}
325325

326326
// Detect scheme on Redox
327-
#[inline]
328-
#[allow(unused_variables)]
329-
fn has_scheme(s: &[u8]) -> bool {
327+
fn has_redox_scheme(s: &[u8]) -> bool {
330328
cfg!(target_os = "redox") && s.split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':')
331329
}
332330

@@ -612,9 +610,6 @@ pub struct Components<'a> {
612610
// normalization, e.g. \\server\share == \\server\share\.
613611
has_physical_root: bool,
614612

615-
// For Redox
616-
has_scheme: bool,
617-
618613
// The iterator is double-ended, and these two states keep track of what has
619614
// been produced from either end
620615
front: State,
@@ -735,7 +730,7 @@ impl<'a> Components<'a> {
735730

736731
/// Is the *original* path rooted?
737732
fn has_root(&self) -> bool {
738-
if self.has_physical_root || self.has_scheme {
733+
if self.has_physical_root {
739734
return true;
740735
}
741736
if let Some(p) = self.prefix {
@@ -1699,7 +1694,7 @@ impl Path {
16991694
self.has_root() && (cfg!(unix) || self.prefix().is_some())
17001695
} else {
17011696
// FIXME: Allow Redox prefixes
1702-
has_scheme(self.as_u8_slice())
1697+
has_redox_scheme(self.as_u8_slice())
17031698
}
17041699
}
17051700

@@ -2064,8 +2059,8 @@ impl Path {
20642059
Components {
20652060
path: self.as_u8_slice(),
20662061
prefix,
2067-
has_physical_root: has_physical_root(self.as_u8_slice(), prefix),
2068-
has_scheme: has_scheme(self.as_u8_slice()),
2062+
has_physical_root: has_physical_root(self.as_u8_slice(), prefix) ||
2063+
has_redox_scheme(self.as_u8_slice()),
20692064
front: State::Prefix,
20702065
back: State::Body,
20712066
}

0 commit comments

Comments
 (0)