Remove some redundant let bindings

This commit is contained in:
David Zbarsky 2015-07-04 13:12:49 -04:00
parent 2e1c9785dc
commit 861ddedaef
8 changed files with 24 additions and 64 deletions

View file

@ -50,9 +50,7 @@ impl CharacterData {
impl<'a> CharacterDataMethods for &'a CharacterData { impl<'a> CharacterDataMethods for &'a CharacterData {
// https://dom.spec.whatwg.org/#dom-characterdata-data // https://dom.spec.whatwg.org/#dom-characterdata-data
fn Data(self) -> DOMString { fn Data(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.data.borrow().clone()
let data = self.data.borrow();
data.clone()
} }
// https://dom.spec.whatwg.org/#dom-characterdata-data // https://dom.spec.whatwg.org/#dom-characterdata-data
@ -62,9 +60,7 @@ impl<'a> CharacterDataMethods for &'a CharacterData {
// https://dom.spec.whatwg.org/#dom-characterdata-length // https://dom.spec.whatwg.org/#dom-characterdata-length
fn Length(self) -> u32 { fn Length(self) -> u32 {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.data.borrow().chars().count() as u32
let data = self.data.borrow();
data.chars().count() as u32
} }
// https://dom.spec.whatwg.org/#dom-characterdata-substringdataoffset-count // https://dom.spec.whatwg.org/#dom-characterdata-substringdataoffset-count

View file

@ -1185,16 +1185,12 @@ impl<'a> DocumentMethods for &'a Document {
// https://dom.spec.whatwg.org/#dom-document-characterset // https://dom.spec.whatwg.org/#dom-document-characterset
fn CharacterSet(self) -> DOMString { fn CharacterSet(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.encoding_name.borrow().clone()
let encoding_name = self.encoding_name.borrow();
encoding_name.clone()
} }
// https://dom.spec.whatwg.org/#dom-document-inputencoding // https://dom.spec.whatwg.org/#dom-document-inputencoding
fn InputEncoding(self) -> DOMString { fn InputEncoding(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.encoding_name.borrow().clone()
let encoding_name = self.encoding_name.borrow();
encoding_name.clone()
} }
// https://dom.spec.whatwg.org/#dom-document-content_type // https://dom.spec.whatwg.org/#dom-document-content_type
@ -1239,9 +1235,7 @@ impl<'a> DocumentMethods for &'a Document {
// https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid // https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
fn GetElementById(self, id: DOMString) -> Option<Root<Element>> { fn GetElementById(self, id: DOMString) -> Option<Root<Element>> {
let id = Atom::from_slice(&id); let id = Atom::from_slice(&id);
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.idmap.borrow().get(&id).map(|ref elements| (*elements)[0].root())
let idmap = self.idmap.borrow();
idmap.get(&id).map(|ref elements| (*elements)[0].root())
} }
// https://dom.spec.whatwg.org/#dom-document-createelement // https://dom.spec.whatwg.org/#dom-document-createelement

View file

@ -67,20 +67,16 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
// https://dom.spec.whatwg.org/#dom-domtokenlist-length // https://dom.spec.whatwg.org/#dom-domtokenlist-length
fn Length(self) -> u32 { fn Length(self) -> u32 {
self.attribute().map(|attr| { self.attribute().map(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let attr = attr.r(); let attr = attr.r();
let value = attr.value(); attr.value().tokens().map(|tokens| tokens.len()).unwrap_or(0)
value.tokens().map(|tokens| tokens.len()).unwrap_or(0)
}).unwrap_or(0) as u32 }).unwrap_or(0) as u32
} }
// https://dom.spec.whatwg.org/#dom-domtokenlist-item // https://dom.spec.whatwg.org/#dom-domtokenlist-item
fn Item(self, index: u32) -> Option<DOMString> { fn Item(self, index: u32) -> Option<DOMString> {
self.attribute().and_then(|attr| { self.attribute().and_then(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let attr = attr.r(); let attr = attr.r();
let value = attr.value(); attr.value().tokens().and_then(|tokens| {
value.tokens().and_then(|tokens| {
tokens.get(index as usize).map(|token| (**token).to_owned()) tokens.get(index as usize).map(|token| (**token).to_owned())
}) })
}) })
@ -96,13 +92,12 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
fn Contains(self, token: DOMString) -> Fallible<bool> { fn Contains(self, token: DOMString) -> Fallible<bool> {
self.check_token_exceptions(&token).map(|token| { self.check_token_exceptions(&token).map(|token| {
self.attribute().map(|attr| { self.attribute().map(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let attr = attr.r(); let attr = attr.r();
let value = attr.value(); attr.value()
value.tokens() .tokens()
.expect("Should have parsed this attribute") .expect("Should have parsed this attribute")
.iter() .iter()
.any(|atom| *atom == token) .any(|atom| *atom == token)
}).unwrap_or(false) }).unwrap_or(false)
}) })
} }

View file

@ -98,9 +98,7 @@ impl<'a> FormDataMethods for &'a FormData {
} }
fn Has(self, name: DOMString) -> bool { fn Has(self, name: DOMString) -> bool {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.data.borrow().contains_key(&name)
let data = self.data.borrow();
data.contains_key(&name)
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
fn Set(self, name: DOMString, value: &Blob, filename: Option<DOMString>) { fn Set(self, name: DOMString, value: &Blob, filename: Option<DOMString>) {

View file

@ -266,9 +266,7 @@ impl<'a> HTMLInputElementMethods for &'a HTMLInputElement {
// https://html.spec.whatwg.org/multipage/#dom-input-value // https://html.spec.whatwg.org/multipage/#dom-input-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-input-value // https://html.spec.whatwg.org/multipage/#dom-input-value

View file

@ -983,13 +983,11 @@ impl<'a> NodeHelpers for &'a Node {
} }
fn get_unique_id(self) -> String { fn get_unique_id(self) -> String {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
if self.unique_id.borrow().is_empty() { if self.unique_id.borrow().is_empty() {
let mut unique_id = self.unique_id.borrow_mut(); let mut unique_id = self.unique_id.borrow_mut();
*unique_id = uuid::Uuid::new_v4().to_simple_string(); *unique_id = uuid::Uuid::new_v4().to_simple_string();
} }
let id = self.unique_id.borrow(); self.unique_id.borrow().clone()
id.clone()
} }
fn summarize(self) -> NodeInfo { fn summarize(self) -> NodeInfo {
@ -2318,10 +2316,7 @@ impl<'a> NodeMethods for &'a Node {
fn is_equal_characterdata(node: &Node, other: &Node) -> bool { fn is_equal_characterdata(node: &Node, other: &Node) -> bool {
let characterdata: &CharacterData = CharacterDataCast::to_ref(node).unwrap(); let characterdata: &CharacterData = CharacterDataCast::to_ref(node).unwrap();
let other_characterdata: &CharacterData = CharacterDataCast::to_ref(other).unwrap(); let other_characterdata: &CharacterData = CharacterDataCast::to_ref(other).unwrap();
// FIXME(https://github.com/rust-lang/rust/issues/23338) *characterdata.data() == *other_characterdata.data()
let own_data = characterdata.data();
let other_data = other_characterdata.data();
*own_data == *other_data
} }
fn is_equal_element_attrs(node: &Node, other: &Node) -> bool { fn is_equal_element_attrs(node: &Node, other: &Node) -> bool {
let element: &Element = ElementCast::to_ref(node).unwrap(); let element: &Element = ElementCast::to_ref(node).unwrap();

View file

@ -89,27 +89,19 @@ impl StorageEvent {
impl<'a> StorageEventMethods for &'a StorageEvent { impl<'a> StorageEventMethods for &'a StorageEvent {
fn GetKey(self) -> Option<DOMString> { fn GetKey(self) -> Option<DOMString> {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.key.borrow().clone()
let key = self.key.borrow();
key.clone()
} }
fn GetOldValue(self) -> Option<DOMString> { fn GetOldValue(self) -> Option<DOMString> {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.oldValue.borrow().clone()
let oldValue = self.oldValue.borrow();
oldValue.clone()
} }
fn GetNewValue(self) -> Option<DOMString> { fn GetNewValue(self) -> Option<DOMString> {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.newValue.borrow().clone()
let newValue = self.newValue.borrow();
newValue.clone()
} }
fn Url(self) -> DOMString { fn Url(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.url.borrow().clone()
let url = self.url.borrow();
url.clone()
} }
fn GetStorageArea(self) -> Option<Root<Storage>> { fn GetStorageArea(self) -> Option<Root<Storage>> {

View file

@ -336,9 +336,7 @@ impl<'a> WindowMethods for &'a Window {
} }
fn Document(self) -> Root<Document> { fn Document(self) -> Root<Document> {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.browser_context().as_ref().unwrap().active_document()
let context = self.browser_context();
context.as_ref().unwrap().active_document()
} }
// https://html.spec.whatwg.org/#dom-location // https://html.spec.whatwg.org/#dom-location
@ -362,9 +360,7 @@ impl<'a> WindowMethods for &'a Window {
// https://html.spec.whatwg.org/#dom-frameelement // https://html.spec.whatwg.org/#dom-frameelement
fn GetFrameElement(self) -> Option<Root<Element>> { fn GetFrameElement(self) -> Option<Root<Element>> {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.browser_context().as_ref().unwrap().frame_element()
let context = self.browser_context();
context.as_ref().unwrap().frame_element()
} }
// https://html.spec.whatwg.org/#dom-navigator // https://html.spec.whatwg.org/#dom-navigator
@ -792,9 +788,7 @@ impl<'a> WindowHelpers for &'a Window {
} }
fn steal_fragment_name(self) -> Option<String> { fn steal_fragment_name(self) -> Option<String> {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.fragment_name.borrow_mut().take()
let mut name = self.fragment_name.borrow_mut();
name.take()
} }
fn set_window_size(self, size: WindowSizeData) { fn set_window_size(self, size: WindowSizeData) {
@ -838,9 +832,7 @@ impl<'a> WindowHelpers for &'a Window {
} }
fn layout_is_idle(self) -> bool { fn layout_is_idle(self) -> bool {
// FIXME(https://github.com/rust-lang/rust/issues/23338) self.layout_join_port.borrow().is_none()
let port = self.layout_join_port.borrow();
port.is_none()
} }
fn get_pending_reflow_count(self) -> u32 { fn get_pending_reflow_count(self) -> u32 {