forked from mirrors/gecko-dev
		
	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. Source-Repo: https://github.com/servo/servo Source-Revision: a9022be0c3e30249845ca5947ac0c0a6743c7991 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 97a17674f72dbfcb99552fe4877789f149ccfc84
		
			
				
	
	
		
			60 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
/* This Source Code Form is subject to the terms of the Mozilla Public
 | 
						|
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 | 
						|
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 | 
						|
 | 
						|
// check-tidy: no specs after this line
 | 
						|
 | 
						|
use dom::bindings::codegen::Bindings::TestWorkletBinding::TestWorkletMethods;
 | 
						|
use dom::bindings::codegen::Bindings::TestWorkletBinding::Wrap;
 | 
						|
use dom::bindings::codegen::Bindings::WorkletBinding::WorkletBinding::WorkletMethods;
 | 
						|
use dom::bindings::codegen::Bindings::WorkletBinding::WorkletOptions;
 | 
						|
use dom::bindings::error::Fallible;
 | 
						|
use dom::bindings::reflector::Reflector;
 | 
						|
use dom::bindings::reflector::reflect_dom_object;
 | 
						|
use dom::bindings::root::{Dom, DomRoot};
 | 
						|
use dom::bindings::str::DOMString;
 | 
						|
use dom::bindings::str::USVString;
 | 
						|
use dom::promise::Promise;
 | 
						|
use dom::window::Window;
 | 
						|
use dom::worklet::Worklet;
 | 
						|
use dom::workletglobalscope::WorkletGlobalScopeType;
 | 
						|
use dom_struct::dom_struct;
 | 
						|
use script_thread::ScriptThread;
 | 
						|
use std::rc::Rc;
 | 
						|
 | 
						|
#[dom_struct]
 | 
						|
pub struct TestWorklet {
 | 
						|
    reflector: Reflector,
 | 
						|
    worklet: Dom<Worklet>,
 | 
						|
}
 | 
						|
 | 
						|
impl TestWorklet {
 | 
						|
    fn new_inherited(worklet: &Worklet) -> TestWorklet {
 | 
						|
        TestWorklet {
 | 
						|
            reflector: Reflector::new(),
 | 
						|
            worklet: Dom::from_ref(worklet),
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    fn new(window: &Window) -> DomRoot<TestWorklet> {
 | 
						|
        let worklet = Worklet::new(window, WorkletGlobalScopeType::Test);
 | 
						|
        reflect_dom_object(Box::new(TestWorklet::new_inherited(&*worklet)), window, Wrap)
 | 
						|
    }
 | 
						|
 | 
						|
    pub fn Constructor(window: &Window) -> Fallible<DomRoot<TestWorklet>> {
 | 
						|
        Ok(TestWorklet::new(window))
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
impl TestWorkletMethods for TestWorklet {
 | 
						|
    #[allow(unrooted_must_root)]
 | 
						|
    fn AddModule(&self, moduleURL: USVString, options: &WorkletOptions) -> Rc<Promise> {
 | 
						|
        self.worklet.AddModule(moduleURL, options)
 | 
						|
    }
 | 
						|
 | 
						|
    fn Lookup(&self, key: DOMString) -> Option<DOMString> {
 | 
						|
        let id = self.worklet.worklet_id();
 | 
						|
        let pool = ScriptThread::worklet_thread_pool();
 | 
						|
        pool.test_worklet_lookup(id, String::from(key)).map(DOMString::from)
 | 
						|
    }
 | 
						|
}
 |