Skip to content

Commit

Permalink
Simplify code for handling Redox paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Aug 22, 2017
1 parent ab48de8 commit fe2d661
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,7 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr {
}

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

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

// For Redox
has_scheme: bool,

// The iterator is double-ended, and these two states keep track of what has
// been produced from either end
front: State,
Expand Down Expand Up @@ -735,7 +730,7 @@ impl<'a> Components<'a> {

/// Is the *original* path rooted?
fn has_root(&self) -> bool {
if self.has_physical_root || self.has_scheme {
if self.has_physical_root {
return true;
}
if let Some(p) = self.prefix {
Expand Down Expand Up @@ -1699,7 +1694,7 @@ impl Path {
self.has_root() && (cfg!(unix) || self.prefix().is_some())
} else {
// FIXME: Allow Redox prefixes
has_scheme(self.as_u8_slice())
has_redox_scheme(self.as_u8_slice())
}
}

Expand Down Expand Up @@ -2064,8 +2059,8 @@ impl Path {
Components {
path: self.as_u8_slice(),
prefix,
has_physical_root: has_physical_root(self.as_u8_slice(), prefix),
has_scheme: has_scheme(self.as_u8_slice()),
has_physical_root: has_physical_root(self.as_u8_slice(), prefix) ||
has_redox_scheme(self.as_u8_slice()),
front: State::Prefix,
back: State::Body,
}
Expand Down

0 comments on commit fe2d661

Please sign in to comment.