comparison rust/hg-core/src/filepatterns.rs @ 48311:6d69e83e6b6e

rhg: more efficient `HgPath::join` This commit makes `HgPath::join` slightly more efficient by avoiding one copy. It also avoids a particularly inefficient (quadratic) use of `HgPath::join` by using a new mutating function `HgPathBuf::push` instead. The name for `HgPathBuf::push` is chosen by analogy to `PathBuf::push`. Differential Revision: https://phab.mercurial-scm.org/D11721
author Arseniy Alekseyev <aalekseyev@janestreet.com>
date Tue, 26 Oct 2021 19:47:30 +0100
parents 0ef8231e413f
children 5fbdd88824dc
comparison
equal deleted inserted replaced
48310:229f5ee1a08a 48311:6d69e83e6b6e
534 let prefix = canonical_path(root_dir, root_dir, new_root)?; 534 let prefix = canonical_path(root_dir, root_dir, new_root)?;
535 535
536 Ok(Self { 536 Ok(Self {
537 prefix: path_to_hg_path_buf(prefix).and_then(|mut p| { 537 prefix: path_to_hg_path_buf(prefix).and_then(|mut p| {
538 if !p.is_empty() { 538 if !p.is_empty() {
539 p.push(b'/'); 539 p.push_byte(b'/');
540 } 540 }
541 Ok(p) 541 Ok(p)
542 })?, 542 })?,
543 path: path.to_owned(), 543 path: path.to_owned(),
544 root: new_root.to_owned(), 544 root: new_root.to_owned(),