Skip to content

Commit

Permalink
Don't unnecessarily clone entire opts::Opt structure.
Browse files Browse the repository at this point in the history
`opts::Opt` is a pretty big structure, so cloning everything is
excessive when we only need a few items.
  • Loading branch information
frewsxcv committed Nov 12, 2016
1 parent 3b2e3dc commit f002029
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions components/servo/lib.rs
Expand Up @@ -87,9 +87,11 @@ use profile::time as profile_time;
use profile_traits::mem;
use profile_traits::time;
use script_traits::{ConstellationMsg, SWManagerSenders, ScriptMsg};
use std::borrow::Cow;
use std::cmp::max;
use std::rc::Rc;
use std::sync::mpsc::Sender;
use url::Url;
use util::opts;
use util::prefs::PREFS;
use util::resource_files::resources_dir_path;
Expand Down Expand Up @@ -173,7 +175,9 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
// Create the constellation, which maintains the engine
// pipelines, including the script and layout threads, as well
// as the navigation context.
let (constellation_chan, sw_senders) = create_constellation(opts.clone(),
let (constellation_chan, sw_senders) = create_constellation(opts.user_agent.clone(),
opts.config_dir.clone(),
opts.url.clone(),
compositor_proxy.clone_compositor_proxy(),
time_profiler_chan.clone(),
mem_profiler_chan.clone(),
Expand Down Expand Up @@ -238,7 +242,9 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
}
}

fn create_constellation(opts: opts::Opts,
fn create_constellation(user_agent: Cow<'static, str>,
config_dir: Option<String>,
url: Option<Url>,
compositor_proxy: Box<CompositorProxy + Send>,
time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: mem::ProfilerChan,
Expand All @@ -250,10 +256,10 @@ fn create_constellation(opts: opts::Opts,
let bluetooth_thread: IpcSender<BluetoothRequest> = BluetoothThreadFactory::new();

let (public_resource_threads, private_resource_threads) =
new_resource_threads(opts.user_agent,
new_resource_threads(user_agent,
devtools_chan.clone(),
time_profiler_chan.clone(),
opts.config_dir.map(Into::into));
config_dir.map(Into::into));
let image_cache_thread = new_image_cache_thread(public_resource_threads.sender(),
webrender_api_sender.create_api());
let font_cache_thread = FontCacheThread::new(public_resource_threads.sender(),
Expand All @@ -280,7 +286,7 @@ fn create_constellation(opts: opts::Opts,
layout_thread::LayoutThread,
script::script_thread::ScriptThread>::start(initial_state);

if let Some(url) = opts.url {
if let Some(url) = url {
constellation_chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
};

Expand Down

0 comments on commit f002029

Please sign in to comment.