]> git.lizzy.rs Git - rust.git/commitdiff
Simplify code for handling Redox paths
authorIan Douglas Scott <ian@iandouglasscott.com>
Tue, 22 Aug 2017 17:33:26 +0000 (10:33 -0700)
committerIan Douglas Scott <ian@iandouglasscott.com>
Tue, 22 Aug 2017 17:33:49 +0000 (10:33 -0700)
src/libstd/path.rs

index 32e1781c3c45c0d9a14ed9a8e540a3c75cc2e1c4..d529b2153e1513eaef5bafb675c2e4e2c04901fb 100644 (file)
@@ -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':')
 }
 
@@ -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,
@@ -735,7 +730,7 @@ pub fn as_path(&self) -> &'a Path {
 
     /// 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 {
@@ -1699,7 +1694,7 @@ pub fn is_absolute(&self) -> bool {
             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())
         }
     }
 
@@ -2064,8 +2059,8 @@ pub fn components(&self) -> Components {
         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,
         }