From 6b7766101f390b41648b4aad0e677450effd1885 Mon Sep 17 00:00:00 2001 From: "David A. Wheeler" Date: Fri, 27 Nov 2020 14:25:54 -0500 Subject: [PATCH] Remove unnecessary clone() calls Remove unnecessary clone() calls; they take more time & removing them makes the code simpler. Signed-off-by: David A. Wheeler --- src/segment_set.rs | 4 ++-- src/util.rs | 2 +- src/verify.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/segment_set.rs b/src/segment_set.rs index ca87b61..cc7aa0e 100644 --- a/src/segment_set.rs +++ b/src/segment_set.rs @@ -319,7 +319,7 @@ impl SegmentSet { // make a wrapper promise to build the proper file result. this // does _not_ run on a worker thread Promise::join(promises) - .map(move |srlist| FileSR(timestamp.map(move |s| (path.clone(), s)), srlist)) + .map(move |srlist| FileSR(timestamp.map(move |s| (path, s)), srlist)) } // read a file from disk (intercessions have already been checked, but @@ -445,7 +445,7 @@ impl SegmentSet { }; // parse and recursively incorporate the initial file - let isegs = read_and_parse(&mut state, path.clone()); + let isegs = read_and_parse(&mut state, path); let isegs = flat(&mut state, isegs.wait()); recurse(&mut state, isegs); diff --git a/src/util.rs b/src/util.rs index dec2922..778a083 100644 --- a/src/util.rs +++ b/src/util.rs @@ -78,7 +78,7 @@ pub fn fast_extend(vec: &mut Vec, other: &[T]) { /// Appends a slice of a byte vector to the end of the same vector. #[inline(always)] pub fn copy_portion(vec: &mut Vec, from: Range) { - let Range { start: copy_start, end: copy_end } = from.clone(); + let Range { start: copy_start, end: copy_end } = from; &vec[from]; // for the bounds check unsafe { let copy_len = copy_end - copy_start; diff --git a/src/verify.rs b/src/verify.rs index 2c763cd..4645507 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -658,7 +658,7 @@ pub fn verify(result: &mut VerifyResult, if let Some(old_res) = old_res_o { if old_res.scope_usage.valid(&nset, &scope) && ptr_eq::(&old_res.source, &sref) { - return (id, old_res.clone()); + return (id, old_res); } } if segments2.options.trace_recalc {