Show More
@@ -290,7 +290,13 b' pub fn relativize_path(path: &HgPath, cw' | |||||
290 | if cwd.as_ref().is_empty() { |
|
290 | if cwd.as_ref().is_empty() { | |
291 | Cow::Borrowed(path.as_bytes()) |
|
291 | Cow::Borrowed(path.as_bytes()) | |
292 | } else { |
|
292 | } else { | |
293 | let mut res: Vec<u8> = Vec::new(); |
|
293 | // This is not all accurate as to how large `res` will actually be, but | |
|
294 | // profiling `rhg files` on a large-ish repo shows it’s better than | |||
|
295 | // starting from a zero-capacity `Vec` and letting `extend` reallocate | |||
|
296 | // repeatedly. | |||
|
297 | let guesstimate = path.as_bytes().len(); | |||
|
298 | ||||
|
299 | let mut res: Vec<u8> = Vec::with_capacity(guesstimate); | |||
294 | let mut path_iter = path.as_bytes().split(|b| *b == b'/').peekable(); |
|
300 | let mut path_iter = path.as_bytes().split(|b| *b == b'/').peekable(); | |
295 | let mut cwd_iter = |
|
301 | let mut cwd_iter = | |
296 | cwd.as_ref().as_bytes().split(|b| *b == b'/').peekable(); |
|
302 | cwd.as_ref().as_bytes().split(|b| *b == b'/').peekable(); |
General Comments 0
You need to be logged in to leave comments.
Login now