Skip to content

Commit

Permalink
servo: Merge #6552 - Remove some redundant let bindings (from dzbarsk…
Browse files Browse the repository at this point in the history
…y:master); r=Ms2ger

Source-Repo: https://github.com/servo/servo
Source-Revision: 236250c3fc7313346e490ce249083bb94d0dad74
  • Loading branch information
dzbarsky committed Jul 4, 2015
1 parent 7239e6d commit 0a2c0b8
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 64 deletions.
8 changes: 2 additions & 6 deletions servo/components/script/dom/characterdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ impl CharacterData {
impl<'a> CharacterDataMethods for &'a CharacterData {
// https://dom.spec.whatwg.org/#dom-characterdata-data
fn Data(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let data = self.data.borrow();
data.clone()
self.data.borrow().clone()
}

// https://dom.spec.whatwg.org/#dom-characterdata-data
Expand All @@ -62,9 +60,7 @@ impl<'a> CharacterDataMethods for &'a CharacterData {

// https://dom.spec.whatwg.org/#dom-characterdata-length
fn Length(self) -> u32 {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let data = self.data.borrow();
data.chars().count() as u32
self.data.borrow().chars().count() as u32
}

// https://dom.spec.whatwg.org/#dom-characterdata-substringdataoffset-count
Expand Down
12 changes: 3 additions & 9 deletions servo/components/script/dom/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,16 +1185,12 @@ impl<'a> DocumentMethods for &'a Document {

// https://dom.spec.whatwg.org/#dom-document-characterset
fn CharacterSet(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let encoding_name = self.encoding_name.borrow();
encoding_name.clone()
self.encoding_name.borrow().clone()
}

// https://dom.spec.whatwg.org/#dom-document-inputencoding
fn InputEncoding(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let encoding_name = self.encoding_name.borrow();
encoding_name.clone()
self.encoding_name.borrow().clone()
}

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

// https://dom.spec.whatwg.org/#dom-document-createelement
Expand Down
19 changes: 7 additions & 12 deletions servo/components/script/dom/domtokenlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,16 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
// https://dom.spec.whatwg.org/#dom-domtokenlist-length
fn Length(self) -> u32 {
self.attribute().map(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let attr = attr.r();
let value = attr.value();
value.tokens().map(|tokens| tokens.len()).unwrap_or(0)
attr.value().tokens().map(|tokens| tokens.len()).unwrap_or(0)
}).unwrap_or(0) as u32
}

// https://dom.spec.whatwg.org/#dom-domtokenlist-item
fn Item(self, index: u32) -> Option<DOMString> {
self.attribute().and_then(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let attr = attr.r();
let value = attr.value();
value.tokens().and_then(|tokens| {
attr.value().tokens().and_then(|tokens| {
tokens.get(index as usize).map(|token| (**token).to_owned())
})
})
Expand All @@ -96,13 +92,12 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
fn Contains(self, token: DOMString) -> Fallible<bool> {
self.check_token_exceptions(&token).map(|token| {
self.attribute().map(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let attr = attr.r();
let value = attr.value();
value.tokens()
.expect("Should have parsed this attribute")
.iter()
.any(|atom| *atom == token)
attr.value()
.tokens()
.expect("Should have parsed this attribute")
.iter()
.any(|atom| *atom == token)
}).unwrap_or(false)
})
}
Expand Down
4 changes: 1 addition & 3 deletions servo/components/script/dom/formdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ impl<'a> FormDataMethods for &'a FormData {
}

fn Has(self, name: DOMString) -> bool {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let data = self.data.borrow();
data.contains_key(&name)
self.data.borrow().contains_key(&name)
}
#[allow(unrooted_must_root)]
fn Set(self, name: DOMString, value: &Blob, filename: Option<DOMString>) {
Expand Down
4 changes: 1 addition & 3 deletions servo/components/script/dom/htmlinputelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ impl<'a> HTMLInputElementMethods for &'a HTMLInputElement {

// https://html.spec.whatwg.org/multipage/#dom-input-value
fn Value(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let textinput = self.textinput.borrow();
textinput.get_content()
self.textinput.borrow().get_content()
}

// https://html.spec.whatwg.org/multipage/#dom-input-value
Expand Down
9 changes: 2 additions & 7 deletions servo/components/script/dom/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,11 @@ impl<'a> NodeHelpers for &'a Node {
}

fn get_unique_id(self) -> String {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
if self.unique_id.borrow().is_empty() {
let mut unique_id = self.unique_id.borrow_mut();
*unique_id = uuid::Uuid::new_v4().to_simple_string();
}
let id = self.unique_id.borrow();
id.clone()
self.unique_id.borrow().clone()
}

fn summarize(self) -> NodeInfo {
Expand Down Expand Up @@ -2318,10 +2316,7 @@ impl<'a> NodeMethods for &'a Node {
fn is_equal_characterdata(node: &Node, other: &Node) -> bool {
let characterdata: &CharacterData = CharacterDataCast::to_ref(node).unwrap();
let other_characterdata: &CharacterData = CharacterDataCast::to_ref(other).unwrap();
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let own_data = characterdata.data();
let other_data = other_characterdata.data();
*own_data == *other_data
*characterdata.data() == *other_characterdata.data()
}
fn is_equal_element_attrs(node: &Node, other: &Node) -> bool {
let element: &Element = ElementCast::to_ref(node).unwrap();
Expand Down
16 changes: 4 additions & 12 deletions servo/components/script/dom/storageevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,19 @@ impl StorageEvent {

impl<'a> StorageEventMethods for &'a StorageEvent {
fn GetKey(self) -> Option<DOMString> {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let key = self.key.borrow();
key.clone()
self.key.borrow().clone()
}

fn GetOldValue(self) -> Option<DOMString> {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let oldValue = self.oldValue.borrow();
oldValue.clone()
self.oldValue.borrow().clone()
}

fn GetNewValue(self) -> Option<DOMString> {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let newValue = self.newValue.borrow();
newValue.clone()
self.newValue.borrow().clone()
}

fn Url(self) -> DOMString {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let url = self.url.borrow();
url.clone()
self.url.borrow().clone()
}

fn GetStorageArea(self) -> Option<Root<Storage>> {
Expand Down
16 changes: 4 additions & 12 deletions servo/components/script/dom/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,7 @@ impl<'a> WindowMethods for &'a Window {
}

fn Document(self) -> Root<Document> {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let context = self.browser_context();
context.as_ref().unwrap().active_document()
self.browser_context().as_ref().unwrap().active_document()
}

// https://html.spec.whatwg.org/#dom-location
Expand All @@ -362,9 +360,7 @@ impl<'a> WindowMethods for &'a Window {

// https://html.spec.whatwg.org/#dom-frameelement
fn GetFrameElement(self) -> Option<Root<Element>> {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let context = self.browser_context();
context.as_ref().unwrap().frame_element()
self.browser_context().as_ref().unwrap().frame_element()
}

// https://html.spec.whatwg.org/#dom-navigator
Expand Down Expand Up @@ -792,9 +788,7 @@ impl<'a> WindowHelpers for &'a Window {
}

fn steal_fragment_name(self) -> Option<String> {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let mut name = self.fragment_name.borrow_mut();
name.take()
self.fragment_name.borrow_mut().take()
}

fn set_window_size(self, size: WindowSizeData) {
Expand Down Expand Up @@ -838,9 +832,7 @@ impl<'a> WindowHelpers for &'a Window {
}

fn layout_is_idle(self) -> bool {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let port = self.layout_join_port.borrow();
port.is_none()
self.layout_join_port.borrow().is_none()
}

fn get_pending_reflow_count(self) -> u32 {
Expand Down

0 comments on commit 0a2c0b8

Please sign in to comment.