Migrate user agent string to Cow<'static, str>.

In most scenarios, where the user of Servo will not override the default
user agent, the user agent can be a `&'static str`. But since we allow
for customization, we currently use a `String` to represent the user
agent. This commit migrates the user agent to be represented as a
`Cow<'static, str>`, which (at the cost of ergonomics) prevents
unnecessary allocations whenever cloning the user agent string in the
scenario the user doesn't override the user agent.
This commit is contained in:
Corey Farwell 2016-10-10 15:30:46 -04:00
parent ef7423bf00
commit 60afad1b61
7 changed files with 66 additions and 63 deletions

View file

@ -252,7 +252,7 @@ fn create_constellation(opts: opts::Opts,
let bluetooth_thread: IpcSender<BluetoothMethodMsg> = BluetoothThreadFactory::new();
let (public_resource_threads, private_resource_threads) =
new_resource_threads(opts.user_agent.clone(),
new_resource_threads(opts.user_agent,
devtools_chan.clone(),
time_profiler_chan.clone(),
opts.config_dir.map(Into::into));