mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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
|
@ -226,7 +226,7 @@ pub unsafe fn create_global_object(
|
|||
// avoid getting trace hooks called on a partially initialized object.
|
||||
JS_SetReservedSlot(rval.get(), DOM_OBJECT_SLOT, PrivateValue(private));
|
||||
let proto_array: Box<ProtoOrIfaceArray> =
|
||||
box [0 as *mut JSObject; PrototypeList::PROTO_OR_IFACE_LENGTH];
|
||||
Box::new([0 as *mut JSObject; PrototypeList::PROTO_OR_IFACE_LENGTH]);
|
||||
JS_SetReservedSlot(rval.get(),
|
||||
DOM_PROTOTYPE_SLOT,
|
||||
PrivateValue(Box::into_raw(proto_array) as *const libc::c_void));
|
||||
|
|
|
@ -62,12 +62,12 @@ impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
|
|||
type_: IteratorType,
|
||||
wrap: unsafe fn(*mut JSContext, &GlobalScope, Box<IterableIterator<T>>)
|
||||
-> DomRoot<Self>) -> DomRoot<Self> {
|
||||
let iterator = box IterableIterator {
|
||||
let iterator = Box::new(IterableIterator {
|
||||
reflector: Reflector::new(),
|
||||
type_: type_,
|
||||
iterable: Dom::from_ref(iterable),
|
||||
index: Cell::new(0),
|
||||
};
|
||||
});
|
||||
reflect_dom_object(iterator, &*iterable.global(), wrap)
|
||||
}
|
||||
|
||||
|
|
|
@ -759,7 +759,7 @@ unsafe impl<T: JSTraceable + 'static> JSTraceable for RootedTraceableBox<T> {
|
|||
impl<T: JSTraceable + 'static> RootedTraceableBox<T> {
|
||||
/// DomRoot a JSTraceable thing for the life of this RootedTraceable
|
||||
pub fn new(traceable: T) -> RootedTraceableBox<T> {
|
||||
let traceable = Box::into_raw(box traceable);
|
||||
let traceable = Box::into_raw(Box::new(traceable));
|
||||
unsafe {
|
||||
RootedTraceableSet::add(traceable);
|
||||
}
|
||||
|
|
|
@ -56,10 +56,10 @@ pub trait WeakReferenceable: DomObject + Sized {
|
|||
.to_private() as *mut WeakBox<Self>;
|
||||
if ptr.is_null() {
|
||||
trace!("Creating new WeakBox holder for {:p}.", self);
|
||||
ptr = Box::into_raw(box WeakBox {
|
||||
ptr = Box::into_raw(Box::new(WeakBox {
|
||||
count: Cell::new(1),
|
||||
value: Cell::new(Some(NonZero::new_unchecked(self))),
|
||||
});
|
||||
}));
|
||||
JS_SetReservedSlot(object, DOM_WEAK_SLOT, PrivateValue(ptr as *const c_void));
|
||||
}
|
||||
let box_ = &*ptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue