[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] [rust] Avoid a clone in contract_protocol_list()
commit 69502942b00ecc944437894b40b286cbfa3df928
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri Oct 27 13:02:14 2017 -0400
[rust] Avoid a clone in contract_protocol_list()
---
src/rust/protover/protover.rs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/rust/protover/protover.rs b/src/rust/protover/protover.rs
index 11e9d0079..f19f7972f 100644
--- a/src/rust/protover/protover.rs
+++ b/src/rust/protover/protover.rs
@@ -429,8 +429,9 @@ fn find_range(list: &Vec<u32>) -> (bool, u32) {
/// A `String` representation of this set in ascending order.
///
fn contract_protocol_list<'a>(supported_set: &'a HashSet<u32>) -> String {
- let mut supported_clone = supported_set.clone();
- let mut supported: Vec<u32> = supported_clone.drain().collect();
+ let mut supported: Vec<u32> = supported_set.iter()
+ .map(|x| *x)
+ .collect();
supported.sort();
let mut final_output: Vec<String> = Vec::new();
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits