Remove some more unnecessary let bindings

This commit is contained in:
David Zbarsky 2015-07-07 05:32:53 -04:00
parent 2947d78e4e
commit bc1eb97671
11 changed files with 29 additions and 84 deletions

View file

@ -212,11 +212,9 @@ pub trait DedicatedWorkerGlobalScopeHelpers {
impl<'a> DedicatedWorkerGlobalScopeHelpers for &'a DedicatedWorkerGlobalScope { impl<'a> DedicatedWorkerGlobalScopeHelpers for &'a DedicatedWorkerGlobalScope {
fn script_chan(self) -> Box<ScriptChan+Send> { fn script_chan(self) -> Box<ScriptChan+Send> {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let worker = self.worker.borrow();
box SendableWorkerScriptChan { box SendableWorkerScriptChan {
sender: self.own_sender.clone(), sender: self.own_sender.clone(),
worker: worker.as_ref().unwrap().clone(), worker: self.worker.borrow().as_ref().unwrap().clone(),
} }
} }

View file

@ -468,10 +468,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
let check_anchor = |&node: &&HTMLAnchorElement| { let check_anchor = |&node: &&HTMLAnchorElement| {
let elem = ElementCast::from_ref(node); let elem = ElementCast::from_ref(node);
elem.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| { elem.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338) &**attr.r().value() == &*fragid
let attr = attr.r();
let value = attr.value();
&**value == &*fragid
}) })
}; };
let doc_node = NodeCast::from_ref(self); let doc_node = NodeCast::from_ref(self);
@ -1562,10 +1559,7 @@ impl<'a> DocumentMethods for &'a Document {
return false; return false;
} }
element.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| { element.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338) &**attr.r().value() == &*name
let attr = attr.r();
let value = attr.value();
&**value == &*name
}) })
}) })
} }

View file

@ -853,21 +853,15 @@ impl<'a> AttributeHandlers for &'a Element {
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name // https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
fn get_attribute_by_name(self, name: DOMString) -> Option<Root<Attr>> { fn get_attribute_by_name(self, name: DOMString) -> Option<Root<Attr>> {
let name = &self.parsed_name(name); let name = &self.parsed_name(name);
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.attrs.borrow().iter().map(|attr| attr.root())
let attrs = self.attrs.borrow();
attrs.iter().map(|attr| attr.root())
.find(|a| a.r().name() == name) .find(|a| a.r().name() == name)
} }
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name // https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
fn get_attributes(self, local_name: &Atom, attributes: &mut RootedVec<JS<Attr>>) { fn get_attributes(self, local_name: &Atom, attributes: &mut RootedVec<JS<Attr>>) {
// FIXME(https://github.com/rust-lang/rust/issues/23338) for ref attr in self.attrs.borrow().iter() {
let attrs = self.attrs.borrow();
for ref attr in attrs.iter() {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let attr = attr.root(); let attr = attr.root();
let attr_local_name = attr.r().local_name(); if attr.r().local_name() == local_name {
if attr_local_name == local_name {
attributes.push(JS::from_rooted(&attr)); attributes.push(JS::from_rooted(&attr));
} }
} }
@ -1010,10 +1004,7 @@ impl<'a> AttributeHandlers for &'a Element {
Quirks => lhs.eq_ignore_ascii_case(&rhs) Quirks => lhs.eq_ignore_ascii_case(&rhs)
}; };
self.get_attribute(&ns!(""), &atom!("class")).map(|attr| { self.get_attribute(&ns!(""), &atom!("class")).map(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338) attr.r().value().tokens().map(|tokens| {
let attr = attr.r();
let value = attr.value();
value.tokens().map(|tokens| {
tokens.iter().any(|atom| is_equal(name, atom)) tokens.iter().any(|atom| is_equal(name, atom))
}).unwrap_or(false) }).unwrap_or(false)
}).unwrap_or(false) }).unwrap_or(false)
@ -1027,12 +1018,8 @@ impl<'a> AttributeHandlers for &'a Element {
fn has_attribute(self, local_name: &Atom) -> bool { fn has_attribute(self, local_name: &Atom) -> bool {
assert!(local_name.bytes().all(|b| b.to_ascii_lowercase() == b)); assert!(local_name.bytes().all(|b| b.to_ascii_lowercase() == b));
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.attrs.borrow().iter().map(|attr| attr.root()).any(|attr| {
let attrs = self.attrs.borrow(); attr.r().local_name() == local_name && attr.r().namespace() == &ns!("")
attrs.iter().map(|attr| attr.root()).any(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let attr = attr.r();
attr.local_name() == local_name && attr.namespace() == &ns!("")
}) })
} }
@ -1077,12 +1064,11 @@ impl<'a> AttributeHandlers for &'a Element {
fn get_tokenlist_attribute(self, local_name: &Atom) -> Vec<Atom> { fn get_tokenlist_attribute(self, local_name: &Atom) -> Vec<Atom> {
self.get_attribute(&ns!(""), local_name).map(|attr| { self.get_attribute(&ns!(""), local_name).map(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338) attr.r()
let attr = attr.r(); .value()
let value = attr.value(); .tokens()
value.tokens() .expect("Expected a TokenListAttrValue")
.expect("Expected a TokenListAttrValue") .to_vec()
.to_vec()
}).unwrap_or(vec!()) }).unwrap_or(vec!())
} }
@ -1663,10 +1649,7 @@ impl<'a> ::selectors::Element for &'a Element {
} }
fn get_id(&self) -> Option<Atom> { fn get_id(&self) -> Option<Atom> {
self.get_attribute(&ns!(""), &atom!("id")).map(|attr| { self.get_attribute(&ns!(""), &atom!("id")).map(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338) match *attr.r().value() {
let attr = attr.r();
let value = attr.value();
match *value {
AttrValue::Atom(ref val) => val.clone(), AttrValue::Atom(ref val) => val.clone(),
_ => panic!("`id` attribute should be AttrValue::Atom"), _ => panic!("`id` attribute should be AttrValue::Atom"),
} }
@ -1735,10 +1718,7 @@ impl<'a> ::selectors::Element for &'a Element {
NamespaceConstraint::Specific(ref ns) => { NamespaceConstraint::Specific(ref ns) => {
self.get_attribute(ns, local_name) self.get_attribute(ns, local_name)
.map_or(false, |attr| { .map_or(false, |attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338) test(&attr.r().value())
let attr = attr.r();
let value = attr.value();
test(&value)
}) })
}, },
NamespaceConstraint::Any => { NamespaceConstraint::Any => {

View file

@ -65,10 +65,8 @@ impl ErrorEvent {
colno: u32, colno: u32,
error: HandleValue) -> Root<ErrorEvent> { error: HandleValue) -> Root<ErrorEvent> {
let ev = ErrorEvent::new_uninitialized(global); let ev = ErrorEvent::new_uninitialized(global);
// FIXME(https://github.com/rust-lang/rust/issues/23338)
{ {
let ev = ev.r(); let event = EventCast::from_ref(ev.r());
let event = EventCast::from_ref(ev);
event.InitEvent(type_, bubbles == EventBubbles::Bubbles, event.InitEvent(type_, bubbles == EventBubbles::Bubbles,
cancelable == EventCancelable::Cancelable); cancelable == EventCancelable::Cancelable);
*ev.message.borrow_mut() = message; *ev.message.borrow_mut() = message;
@ -125,15 +123,11 @@ impl<'a> ErrorEventMethods for &'a ErrorEvent {
} }
fn Message(self) -> DOMString { fn Message(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.message.borrow().clone()
let message = self.message.borrow();
message.clone()
} }
fn Filename(self) -> DOMString { fn Filename(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.filename.borrow().clone()
let filename = self.filename.borrow();
filename.clone()
} }
fn Error(self, _cx: *mut JSContext) -> JSVal { fn Error(self, _cx: *mut JSContext) -> JSVal {

View file

@ -180,9 +180,7 @@ impl<'a> EventMethods for &'a Event {
// https://dom.spec.whatwg.org/#dom-event-type // https://dom.spec.whatwg.org/#dom-event-type
fn Type(self) -> DOMString { fn Type(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.type_.borrow().clone()
let type_ = self.type_.borrow();
type_.clone()
} }
// https://dom.spec.whatwg.org/#dom-event-target // https://dom.spec.whatwg.org/#dom-event-target

View file

@ -282,9 +282,7 @@ impl<'a> EventTargetHelpers for &'a EventTarget {
} }
fn has_handlers(self) -> bool { fn has_handlers(self) -> bool {
// FIXME(https://github.com/rust-lang/rust/issues/23338) !self.handlers.borrow().is_empty()
let handlers = self.handlers.borrow();
!handlers.is_empty()
} }
} }

View file

@ -250,10 +250,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for &'a HTMLElement {
let element = ElementCast::from_ref(self); let element = ElementCast::from_ref(self);
let local_name = Atom::from_slice(&to_snake_case(local_name)); let local_name = Atom::from_slice(&to_snake_case(local_name));
element.get_attribute(&ns!(""), &local_name).map(|attr| { element.get_attribute(&ns!(""), &local_name).map(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338) (**attr.r().value()).to_owned()
let attr = attr.r();
let value = attr.value();
(**value).to_owned()
}) })
} }

View file

@ -189,9 +189,7 @@ impl<'a> HTMLTextAreaElementMethods for &'a HTMLTextAreaElement {
// https://html.spec.whatwg.org/multipage/#dom-textarea-value // https://html.spec.whatwg.org/multipage/#dom-textarea-value
fn Value(self) -> DOMString { fn Value(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.textinput.borrow().get_content()
let textinput = self.textinput.borrow();
textinput.get_content()
} }
// https://html.spec.whatwg.org/multipage/#dom-textarea-value // https://html.spec.whatwg.org/multipage/#dom-textarea-value

View file

@ -784,15 +784,11 @@ impl<'a> KeyboardEventMethods for &'a KeyboardEvent {
} }
fn Key(self) -> DOMString { fn Key(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.key_string.borrow().clone()
let key_string = self.key_string.borrow();
key_string.clone()
} }
fn Code(self) -> DOMString { fn Code(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.code.borrow().clone()
let code = self.code.borrow();
code.clone()
} }
fn Location(self) -> u32 { fn Location(self) -> u32 {

View file

@ -45,15 +45,11 @@ impl URLSearchParams {
match init { match init {
Some(eString(init)) => { Some(eString(init)) => {
// Step 2. // Step 2.
let query = query.r(); *query.r().list.borrow_mut() = parse(init.as_bytes());
*query.list.borrow_mut() = parse(init.as_bytes());
}, },
Some(eURLSearchParams(init)) => { Some(eURLSearchParams(init)) => {
// Step 3. // Step 3.
// FIXME(https://github.com/rust-lang/rust/issues/23338) *query.r().list.borrow_mut() = init.r().list.borrow().clone();
let query = query.r();
let init = init.r();
*query.list.borrow_mut() = init.list.borrow().clone();
}, },
None => {} None => {}
} }

View file

@ -623,9 +623,7 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
// https://xhr.spec.whatwg.org/#the-statustext-attribute // https://xhr.spec.whatwg.org/#the-statustext-attribute
fn StatusText(self) -> ByteString { fn StatusText(self) -> ByteString {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.status_text.borrow().clone()
let status_text = self.status_text.borrow();
status_text.clone()
} }
// https://xhr.spec.whatwg.org/#the-getresponseheader()-method // https://xhr.spec.whatwg.org/#the-getresponseheader()-method
@ -1031,11 +1029,9 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
} }
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let response = self.response.borrow();
// According to Simon, decode() should never return an error, so unwrap()ing // According to Simon, decode() should never return an error, so unwrap()ing
// the result should be fine. XXXManishearth have a closer look at this later // the result should be fine. XXXManishearth have a closer look at this later
encoding.decode(&response, DecoderTrap::Replace).unwrap().to_owned() encoding.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap().to_owned()
} }
fn filter_response_headers(self) -> Headers { fn filter_response_headers(self) -> Headers {
// https://fetch.spec.whatwg.org/#concept-response-header-list // https://fetch.spec.whatwg.org/#concept-response-header-list