Skip to content

Commit

Permalink
Avoid allocation when checking for windows drive letters.
Browse files Browse the repository at this point in the history
  • Loading branch information
o0Ignition0o committed Dec 1, 2019
1 parent bfcda54 commit 2103271
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,18 +1314,11 @@ impl<'a> Parser<'a> {
if self.serialization.len() == path_start {
return;
}
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return.
if scheme_type.is_file()
&& is_normalized_windows_drive_letter(&self.serialization[path_start..])
{
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return.
let segments: Vec<&str> = self.serialization[path_start..]
.split('/')
.filter(|s| !s.is_empty())
.collect();
if scheme_type.is_file()
&& segments.len() == 1
&& is_normalized_windows_drive_letter(segments[0])
{
return;
}
return;
}
// Remove path’s last item.
self.pop_path(scheme_type, path_start);
Expand Down

0 comments on commit 2103271

Please sign in to comment.