mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Remove use of unstable box syntax.
http://www.robohornet.org gives a score of 101.36 on master, and 102.68 with this PR. The latter is slightly better, but probably within noise level. So it looks like this PR does not affect DOM performance. This is expected since `Box::new` is defined as: ```rust impl<T> Box<T> { #[inline(always)] pub fn new(x: T) -> Box<T> { box x } } ``` With inlining, it should compile to the same as box syntax.
This commit is contained in:
parent
a5100e3c78
commit
aa15dc269f
270 changed files with 580 additions and 514 deletions
|
@ -2312,20 +2312,24 @@ impl Document {
|
|||
referrer: Option<String>,
|
||||
referrer_policy: Option<ReferrerPolicy>)
|
||||
-> DomRoot<Document> {
|
||||
let document = reflect_dom_object(box Document::new_inherited(window,
|
||||
has_browsing_context,
|
||||
url,
|
||||
origin,
|
||||
doctype,
|
||||
content_type,
|
||||
last_modified,
|
||||
activity,
|
||||
source,
|
||||
doc_loader,
|
||||
referrer,
|
||||
referrer_policy),
|
||||
window,
|
||||
DocumentBinding::Wrap);
|
||||
let document = reflect_dom_object(
|
||||
Box::new(Document::new_inherited(
|
||||
window,
|
||||
has_browsing_context,
|
||||
url,
|
||||
origin,
|
||||
doctype,
|
||||
content_type,
|
||||
last_modified,
|
||||
activity,
|
||||
source,
|
||||
doc_loader,
|
||||
referrer,
|
||||
referrer_policy
|
||||
)),
|
||||
window,
|
||||
DocumentBinding::Wrap
|
||||
);
|
||||
{
|
||||
let node = document.upcast::<Node>();
|
||||
node.set_owner_doc(&document);
|
||||
|
@ -3344,7 +3348,7 @@ impl DocumentMethods for Document {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-document-images
|
||||
fn Images(&self) -> DomRoot<HTMLCollection> {
|
||||
self.images.or_init(|| {
|
||||
let filter = box ImagesFilter;
|
||||
let filter = Box::new(ImagesFilter);
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
})
|
||||
}
|
||||
|
@ -3352,7 +3356,7 @@ impl DocumentMethods for Document {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-document-embeds
|
||||
fn Embeds(&self) -> DomRoot<HTMLCollection> {
|
||||
self.embeds.or_init(|| {
|
||||
let filter = box EmbedsFilter;
|
||||
let filter = Box::new(EmbedsFilter);
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
})
|
||||
}
|
||||
|
@ -3365,7 +3369,7 @@ impl DocumentMethods for Document {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-document-links
|
||||
fn Links(&self) -> DomRoot<HTMLCollection> {
|
||||
self.links.or_init(|| {
|
||||
let filter = box LinksFilter;
|
||||
let filter = Box::new(LinksFilter);
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
})
|
||||
}
|
||||
|
@ -3373,7 +3377,7 @@ impl DocumentMethods for Document {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-document-forms
|
||||
fn Forms(&self) -> DomRoot<HTMLCollection> {
|
||||
self.forms.or_init(|| {
|
||||
let filter = box FormsFilter;
|
||||
let filter = Box::new(FormsFilter);
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
})
|
||||
}
|
||||
|
@ -3381,7 +3385,7 @@ impl DocumentMethods for Document {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-document-scripts
|
||||
fn Scripts(&self) -> DomRoot<HTMLCollection> {
|
||||
self.scripts.or_init(|| {
|
||||
let filter = box ScriptsFilter;
|
||||
let filter = Box::new(ScriptsFilter);
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
})
|
||||
}
|
||||
|
@ -3389,7 +3393,7 @@ impl DocumentMethods for Document {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-document-anchors
|
||||
fn Anchors(&self) -> DomRoot<HTMLCollection> {
|
||||
self.anchors.or_init(|| {
|
||||
let filter = box AnchorsFilter;
|
||||
let filter = Box::new(AnchorsFilter);
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
})
|
||||
}
|
||||
|
@ -3398,7 +3402,7 @@ impl DocumentMethods for Document {
|
|||
fn Applets(&self) -> DomRoot<HTMLCollection> {
|
||||
// FIXME: This should be return OBJECT elements containing applets.
|
||||
self.applets.or_init(|| {
|
||||
let filter = box AppletsFilter;
|
||||
let filter = Box::new(AppletsFilter);
|
||||
HTMLCollection::create(&self.window, self.upcast(), filter)
|
||||
})
|
||||
}
|
||||
|
@ -3610,7 +3614,7 @@ impl DocumentMethods for Document {
|
|||
let filter = NamedElementFilter {
|
||||
name: name,
|
||||
};
|
||||
let collection = HTMLCollection::create(self.window(), root, box filter);
|
||||
let collection = HTMLCollection::create(self.window(), root, Box::new(filter));
|
||||
Some(NonZero::new_unchecked(collection.reflector().get_jsobject().get()))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue