Skip to content

Commit 2103271

Browse files
committed
Avoid allocation when checking for windows drive letters.
1 parent bfcda54 commit 2103271

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/parser.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -1314,18 +1314,11 @@ impl<'a> Parser<'a> {
13141314
if self.serialization.len() == path_start {
13151315
return;
13161316
}
1317+
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return.
1318+
if scheme_type.is_file()
1319+
&& is_normalized_windows_drive_letter(&self.serialization[path_start..])
13171320
{
1318-
// If url’s scheme is "file", path’s size is 1, and path[0] is a normalized Windows drive letter, then return.
1319-
let segments: Vec<&str> = self.serialization[path_start..]
1320-
.split('/')
1321-
.filter(|s| !s.is_empty())
1322-
.collect();
1323-
if scheme_type.is_file()
1324-
&& segments.len() == 1
1325-
&& is_normalized_windows_drive_letter(segments[0])
1326-
{
1327-
return;
1328-
}
1321+
return;
13291322
}
13301323
// Remove path’s last item.
13311324
self.pop_path(scheme_type, path_start);

0 commit comments

Comments
 (0)