Don't clone the result of AttrHelpersForLayout::local_name

There is no need to do that. Embrace returning borrows from the DOM, it good.
This commit is contained in:
Anthony Ramine 2020-03-31 14:02:14 +02:00
parent 4db84bede8
commit 47c9f19121
2 changed files with 5 additions and 5 deletions

View file

@ -237,7 +237,7 @@ pub trait AttrHelpersForLayout<'dom> {
fn value(self) -> &'dom AttrValue;
fn as_str(self) -> &'dom str;
fn as_tokens(self) -> Option<&'dom [Atom]>;
fn local_name(self) -> LocalName;
fn local_name(self) -> &'dom LocalName;
}
#[allow(unsafe_code)]
@ -262,7 +262,7 @@ impl<'dom> AttrHelpersForLayout<'dom> for LayoutDom<'dom, Attr> {
}
#[inline]
fn local_name(self) -> LocalName {
unsafe { self.unsafe_get().identifier.local_name.clone() }
fn local_name(self) -> &'dom LocalName {
unsafe { &self.unsafe_get().identifier.local_name }
}
}

View file

@ -578,7 +578,7 @@ pub unsafe fn get_attr_for_layout<'dom>(
.iter()
.find(|attr| {
let attr = attr.to_layout();
*name == attr.local_name() && (*attr.unsafe_get()).namespace() == namespace
name == attr.local_name() && (*attr.unsafe_get()).namespace() == namespace
})
.map(|attr| attr.to_layout())
}
@ -610,7 +610,7 @@ impl RawLayoutElementHelpers for Element {
.iter()
.filter_map(|attr| {
let attr = attr.to_layout();
if *name == attr.local_name() {
if name == attr.local_name() {
Some(attr.value())
} else {
None