From 13291c4b64032931a38cd0671075287d87594732 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 2 Nov 2015 16:04:10 +0100 Subject: [PATCH 1/2] Avoid some string copies in handle_modify_attribute. --- components/script/devtools.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/script/devtools.rs b/components/script/devtools.rs index bc6dc34ad4f..3ea1448e099 100644 --- a/components/script/devtools.rs +++ b/components/script/devtools.rs @@ -155,12 +155,12 @@ pub fn handle_modify_attribute(page: &Rc, let node = find_node_by_unique_id(&*page, pipeline, node_id); let elem = node.downcast::().expect("should be getting layout of element"); - for modification in &modifications { + for modification in modifications { match modification.newValue { - Some(ref string) => { - let _ = elem.SetAttribute(modification.attributeName.clone(), string.clone()); + Some(string) => { + let _ = elem.SetAttribute(modification.attributeName, string); }, - None => elem.RemoveAttribute(modification.attributeName.clone()), + None => elem.RemoveAttribute(modification.attributeName), } } } From d3d1f2b5c458e81c7596df0723dd75b28fe052f6 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 2 Nov 2015 16:04:24 +0100 Subject: [PATCH 2/2] Simplify DOMTokenList::Item. --- components/script/dom/domtokenlist.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index c3944b7627c..4c2a9769c15 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -64,10 +64,7 @@ impl DOMTokenListMethods for DOMTokenList { // https://dom.spec.whatwg.org/#dom-domtokenlist-item fn Item(&self, index: u32) -> Option { self.attribute().and_then(|attr| { - let attr = attr.r(); - Some(attr.value().as_tokens()).and_then(|tokens| { - tokens.get(index as usize).map(|token| (**token).to_owned()) - }) + attr.value().as_tokens().get(index as usize).map(|token| (**token).to_owned()) }) }