From patchwork Sat Aug 17 12:12:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [02,of,11] rust-dirstate: remove unneeded "ref" From: Yuya Nishihara X-Patchwork-Id: 41324 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sat, 17 Aug 2019 21:12:03 +0900 # HG changeset patch # User Yuya Nishihara # Date 1566009785 -32400 # Sat Aug 17 11:43:05 2019 +0900 # Node ID e04eef69a482c886117a6aaa604d8dce6e3e1d3a # Parent 809ab6f869baaa800f15fd6ab4003c480bd0871f rust-dirstate: remove unneeded "ref" At 7cae6bc29ff9, .to_owned() was rewritten as .to_owned().to_vec(), which is no longer needed since the filename is a single reference. diff --git a/rust/hg-core/src/dirstate/parsers.rs b/rust/hg-core/src/dirstate/parsers.rs --- a/rust/hg-core/src/dirstate/parsers.rs +++ b/rust/hg-core/src/dirstate/parsers.rs @@ -92,7 +92,7 @@ pub fn pack_dirstate( .iter() .map(|(filename, _)| { let mut length = MIN_ENTRY_SIZE + filename.len(); - if let Some(ref copy) = copy_map.get(filename) { + if let Some(copy) = copy_map.get(filename) { length += copy.len() + 1; } length @@ -106,8 +106,8 @@ pub fn pack_dirstate( packed.extend(&parents.p1); packed.extend(&parents.p2); - for (ref filename, entry) in state_map.iter() { - let mut new_filename: Vec = filename.to_vec(); + for (filename, entry) in state_map.iter() { + let mut new_filename: Vec = filename.to_owned(); let mut new_mtime: i32 = entry.mtime; if entry.state == EntryState::Normal && entry.mtime == now { // The file was last modified "simultaneously" with the current @@ -121,7 +121,7 @@ pub fn pack_dirstate( // mistakenly treating such files as clean. new_mtime = -1; new_state_map.push(( - filename.to_owned().to_vec(), + filename.to_owned(), DirstateEntry { mtime: new_mtime, ..*entry @@ -129,7 +129,7 @@ pub fn pack_dirstate( )); } - if let Some(copy) = copy_map.get(*filename) { + if let Some(copy) = copy_map.get(filename) { new_filename.push('\0' as u8); new_filename.extend(copy); }