From 9bd1e7f295e7f3937d244e9724cb60a28602fc63 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 24 May 2017 23:00:38 +0100 Subject: [PATCH] jingle_s5b: Remove the clones. --- src/jingle_s5b.rs | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/jingle_s5b.rs b/src/jingle_s5b.rs index fa5ee667..42c188f8 100644 --- a/src/jingle_s5b.rs +++ b/src/jingle_s5b.rs @@ -67,12 +67,12 @@ impl Into for Candidate { fn into(self) -> Element { Element::builder("candidate") .ns(ns::JINGLE_S5B) - .attr("cid", self.cid.clone()) - .attr("host", self.host.clone()) - .attr("jid", self.jid.clone()) + .attr("cid", self.cid) + .attr("host", self.host) + .attr("jid", self.jid) .attr("port", match self.port { Some(port) => Some(format!("{}", port)), None => None }) .attr("priority", format!("{}", self.priority)) - .attr("type", self.type_.clone()) + .attr("type", self.type_) .build() } } @@ -143,22 +143,16 @@ impl TryFrom for Transport { payload = Some(if child.is("candidate", ns::JINGLE_S5B) { let mut candidates = match payload { Some(TransportPayload::Candidates(candidates)) => candidates, - Some(_) => return Err(Error::ParseError("Non-activated child already present in JingleS5B transport element.")), + Some(_) => return Err(Error::ParseError("Non-candidate child already present in JingleS5B transport element.")), None => vec!(), }; - let cid = get_attr!(child, "cid", required); - let host = get_attr!(child, "host", required); - let jid = get_attr!(child, "jid", required); - let port = get_attr!(child, "port", optional); - let priority = get_attr!(child, "priority", required); - let type_ = get_attr!(child, "type", default); candidates.push(Candidate { - cid: cid, - host: host, - jid: jid, - port: port, - priority: priority, - type_: type_, + cid: get_attr!(child, "cid", required), + host: get_attr!(child, "host", required), + jid: get_attr!(child, "jid", required), + port: get_attr!(child, "port", optional), + priority: get_attr!(child, "priority", required), + type_: get_attr!(child, "type", default), }); TransportPayload::Candidates(candidates) } else if child.is("activated", ns::JINGLE_S5B) { @@ -204,13 +198,13 @@ impl Into for Transport { fn into(self) -> Element { Element::builder("transport") .ns(ns::JINGLE_S5B) - .attr("sid", self.sid.clone()) - .attr("dstaddr", self.dstaddr.clone()) - .attr("mode", self.mode.clone()) + .attr("sid", self.sid) + .attr("dstaddr", self.dstaddr) + .attr("mode", self.mode) .append(match self.payload { - TransportPayload::Candidates(candidates) => { - candidates.iter() - .map(|candidate| -> Element { candidate.clone().into() }) + TransportPayload::Candidates(mut candidates) => { + candidates.drain(..) + .map(|candidate| candidate.into()) .collect::>() }, TransportPayload::Activated(cid) => {