mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #14181 - frewsxcv:opt-clone, r=nox
Don't unnecessarily clone entire `opts::Opt` structure. `opts::Opt` is a pretty big structure, so cloning everything is excessive when we only need a few items. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14181) <!-- Reviewable:end -->
This commit is contained in:
commit
2d0c7166f1
2 changed files with 14 additions and 7 deletions
|
@ -87,9 +87,12 @@ use profile::time as profile_time;
|
||||||
use profile_traits::mem;
|
use profile_traits::mem;
|
||||||
use profile_traits::time;
|
use profile_traits::time;
|
||||||
use script_traits::{ConstellationMsg, SWManagerSenders, ScriptMsg};
|
use script_traits::{ConstellationMsg, SWManagerSenders, ScriptMsg};
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
|
use url::Url;
|
||||||
use util::opts;
|
use util::opts;
|
||||||
use util::prefs::PREFS;
|
use util::prefs::PREFS;
|
||||||
use util::resource_files::resources_dir_path;
|
use util::resource_files::resources_dir_path;
|
||||||
|
@ -177,7 +180,9 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
|
||||||
// Create the constellation, which maintains the engine
|
// Create the constellation, which maintains the engine
|
||||||
// pipelines, including the script and layout threads, as well
|
// pipelines, including the script and layout threads, as well
|
||||||
// as the navigation context.
|
// 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(),
|
compositor_proxy.clone_compositor_proxy(),
|
||||||
time_profiler_chan.clone(),
|
time_profiler_chan.clone(),
|
||||||
mem_profiler_chan.clone(),
|
mem_profiler_chan.clone(),
|
||||||
|
@ -242,7 +247,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<PathBuf>,
|
||||||
|
url: Option<Url>,
|
||||||
compositor_proxy: Box<CompositorProxy + Send>,
|
compositor_proxy: Box<CompositorProxy + Send>,
|
||||||
time_profiler_chan: time::ProfilerChan,
|
time_profiler_chan: time::ProfilerChan,
|
||||||
mem_profiler_chan: mem::ProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
|
@ -254,10 +261,10 @@ fn create_constellation(opts: opts::Opts,
|
||||||
let bluetooth_thread: IpcSender<BluetoothRequest> = BluetoothThreadFactory::new();
|
let bluetooth_thread: IpcSender<BluetoothRequest> = BluetoothThreadFactory::new();
|
||||||
|
|
||||||
let (public_resource_threads, private_resource_threads) =
|
let (public_resource_threads, private_resource_threads) =
|
||||||
new_resource_threads(opts.user_agent,
|
new_resource_threads(user_agent,
|
||||||
devtools_chan.clone(),
|
devtools_chan.clone(),
|
||||||
time_profiler_chan.clone(),
|
time_profiler_chan.clone(),
|
||||||
opts.config_dir.map(Into::into));
|
config_dir);
|
||||||
let image_cache_thread = new_image_cache_thread(public_resource_threads.sender(),
|
let image_cache_thread = new_image_cache_thread(public_resource_threads.sender(),
|
||||||
webrender_api_sender.create_api());
|
webrender_api_sender.create_api());
|
||||||
let font_cache_thread = FontCacheThread::new(public_resource_threads.sender(),
|
let font_cache_thread = FontCacheThread::new(public_resource_threads.sender(),
|
||||||
|
@ -284,7 +291,7 @@ fn create_constellation(opts: opts::Opts,
|
||||||
layout_thread::LayoutThread,
|
layout_thread::LayoutThread,
|
||||||
script::script_thread::ScriptThread>::start(initial_state);
|
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();
|
constellation_chan.send(ConstellationMsg::InitLoadUrl(url)).unwrap();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ pub struct Opts {
|
||||||
pub use_msaa: bool,
|
pub use_msaa: bool,
|
||||||
|
|
||||||
/// Directory for a default config directory
|
/// Directory for a default config directory
|
||||||
pub config_dir: Option<String>,
|
pub config_dir: Option<PathBuf>,
|
||||||
|
|
||||||
// don't skip any backtraces on panic
|
// don't skip any backtraces on panic
|
||||||
pub full_backtraces: bool,
|
pub full_backtraces: bool,
|
||||||
|
@ -857,7 +857,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
||||||
enable_vsync: !debug_options.disable_vsync,
|
enable_vsync: !debug_options.disable_vsync,
|
||||||
webrender_stats: debug_options.webrender_stats,
|
webrender_stats: debug_options.webrender_stats,
|
||||||
use_msaa: debug_options.use_msaa,
|
use_msaa: debug_options.use_msaa,
|
||||||
config_dir: opt_match.opt_str("config-dir"),
|
config_dir: opt_match.opt_str("config-dir").map(Into::into),
|
||||||
full_backtraces: debug_options.full_backtraces,
|
full_backtraces: debug_options.full_backtraces,
|
||||||
is_printing_version: is_printing_version,
|
is_printing_version: is_printing_version,
|
||||||
webrender_debug: debug_options.webrender_debug,
|
webrender_debug: debug_options.webrender_debug,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue