mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Reduce copying on parse_url() call sites.
This commit is contained in:
parent
fe1bb6a325
commit
d3cbdd8865
7 changed files with 41 additions and 41 deletions
|
@ -563,7 +563,7 @@ impl IOCompositor {
|
|||
None => fail!("Compositor: Received LoadUrlWindowEvent without initialized compositor layers"),
|
||||
};
|
||||
|
||||
let msg = LoadUrlMsg(root_pipeline_id, url::parse_url(url_string.to_str(), None));
|
||||
let msg = LoadUrlMsg(root_pipeline_id, url::parse_url(url_string, None));
|
||||
self.constellation_chan.send(msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -390,7 +390,7 @@ impl Constellation {
|
|||
self.profiler_chan.clone(),
|
||||
self.window_size,
|
||||
self.opts.clone());
|
||||
let failure = ~"about:failure";
|
||||
let failure = "about:failure";
|
||||
let url = parse_url(failure, None);
|
||||
pipeline.load(url);
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ fn run(opts: Opts) {
|
|||
|
||||
// Send the URL command to the constellation.
|
||||
for filename in opts.urls.iter() {
|
||||
constellation_chan.send(InitLoadUrlMsg(parse_url(filename.clone(), None)))
|
||||
constellation_chan.send(InitLoadUrlMsg(parse_url(*filename, None)))
|
||||
}
|
||||
|
||||
// Send the constallation Chan as the result
|
||||
|
|
|
@ -494,7 +494,7 @@ mod tests {
|
|||
loop {
|
||||
match port.recv() {
|
||||
resource_task::Load(_, response) => {
|
||||
let chan = start_sending(response, Metadata::default(parse_url(~"file:///fake", None)));
|
||||
let chan = start_sending(response, Metadata::default(parse_url("file:///fake", None)));
|
||||
on_load(chan);
|
||||
}
|
||||
resource_task::Exit => break
|
||||
|
@ -508,7 +508,7 @@ mod tests {
|
|||
let mock_resource_task = mock_resource_task(proc(_response) {});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let _url = parse_url(~"file", None);
|
||||
let _url = parse_url("file", None);
|
||||
|
||||
image_cache_task.exit();
|
||||
mock_resource_task.send(resource_task::Exit);
|
||||
|
@ -520,7 +520,7 @@ mod tests {
|
|||
let mock_resource_task = mock_resource_task(proc(_response) {});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
let (port, chan) = Chan::new();
|
||||
image_cache_task.send(GetImage(url, chan));
|
||||
|
@ -537,7 +537,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
image_cache_task.send(Prefetch(url));
|
||||
url_requested.recv();
|
||||
|
@ -555,7 +555,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
image_cache_task.send(Prefetch(url.clone()));
|
||||
image_cache_task.send(Prefetch(url));
|
||||
|
@ -578,7 +578,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
image_cache_task.send(Prefetch(url.clone()));
|
||||
image_cache_task.send(Decode(url.clone()));
|
||||
|
@ -598,7 +598,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
let join_port = image_cache_task.wait_for_store();
|
||||
|
||||
|
@ -627,7 +627,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
let join_port = image_cache_task.wait_for_store();
|
||||
|
||||
|
@ -660,7 +660,7 @@ mod tests {
|
|||
loop {
|
||||
match port.recv() {
|
||||
resource_task::Load(_, response) => {
|
||||
let chan = start_sending(response, Metadata::default(parse_url(~"file:///fake", None)));
|
||||
let chan = start_sending(response, Metadata::default(parse_url("file:///fake", None)));
|
||||
chan.send(resource_task::Payload(test_image_bin()));
|
||||
chan.send(resource_task::Done(Ok(())));
|
||||
image_bin_sent_chan.send(());
|
||||
|
@ -674,7 +674,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
image_cache_task.send(Prefetch(url.clone()));
|
||||
|
||||
|
@ -703,7 +703,7 @@ mod tests {
|
|||
loop {
|
||||
match port.recv() {
|
||||
resource_task::Load(_, response) => {
|
||||
let chan = start_sending(response, Metadata::default(parse_url(~"file:///fake", None)));
|
||||
let chan = start_sending(response, Metadata::default(parse_url("file:///fake", None)));
|
||||
chan.send(resource_task::Payload(test_image_bin()));
|
||||
chan.send(resource_task::Done(Err(())));
|
||||
image_bin_sent_chan.send(());
|
||||
|
@ -717,7 +717,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
image_cache_task.send(Prefetch(url.clone()));
|
||||
image_cache_task.send(Decode(url.clone()));
|
||||
|
@ -747,7 +747,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
let join_port = image_cache_task.wait_for_store_prefetched();
|
||||
|
||||
|
@ -777,7 +777,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
let join_port = image_cache_task.wait_for_store_prefetched();
|
||||
|
||||
|
@ -815,7 +815,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
let join_port = image_cache_task.wait_for_store();
|
||||
|
||||
|
@ -846,7 +846,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
let join_port = image_cache_task.wait_for_store();
|
||||
|
||||
|
@ -878,7 +878,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
image_cache_task.send(Prefetch(url.clone()));
|
||||
image_cache_task.send(Decode(url.clone()));
|
||||
|
@ -908,7 +908,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = ImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
image_cache_task.send(Prefetch(url.clone()));
|
||||
image_cache_task.send(Decode(url.clone()));
|
||||
|
@ -935,7 +935,7 @@ mod tests {
|
|||
});
|
||||
|
||||
let image_cache_task = SyncImageCacheTask(mock_resource_task.clone());
|
||||
let url = parse_url(~"file", None);
|
||||
let url = parse_url("file", None);
|
||||
|
||||
image_cache_task.send(Prefetch(url.clone()));
|
||||
image_cache_task.send(Decode(url.clone()));
|
||||
|
|
|
@ -343,7 +343,7 @@ pub fn parse_html(cx: *JSContext,
|
|||
(Some(rel), Some(href)) => {
|
||||
if "stylesheet" == rel.value_ref() {
|
||||
debug!("found CSS stylesheet: {:s}", href.value_ref());
|
||||
let url = parse_url(href.Value(), Some(url2.clone()));
|
||||
let url = parse_url(href.value_ref(), Some(url2.clone()));
|
||||
css_chan2.send(CSSTaskNewFile(UrlProvenance(url)));
|
||||
}
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ pub fn parse_html(cx: *JSContext,
|
|||
let elem = &mut iframe_element.htmlelement.element;
|
||||
let src_opt = elem.get_attribute(Null, "src").map(|x| x.Value());
|
||||
for src in src_opt.iter() {
|
||||
let iframe_url = parse_url(src.clone(), Some(url2.clone()));
|
||||
let iframe_url = parse_url(*src, Some(url2.clone()));
|
||||
iframe_element.frame = Some(iframe_url.clone());
|
||||
|
||||
// Subpage Id
|
||||
|
@ -458,7 +458,7 @@ pub fn parse_html(cx: *JSContext,
|
|||
match script.get_attribute(Null, "src") {
|
||||
Some(src) => {
|
||||
debug!("found script: {:s}", src.Value());
|
||||
let new_url = parse_url(src.Value(), Some(url3.clone()));
|
||||
let new_url = parse_url(src.value_ref(), Some(url3.clone()));
|
||||
js_chan2.send(JSTaskNewFile(new_url));
|
||||
}
|
||||
None => {
|
||||
|
|
|
@ -895,7 +895,7 @@ impl ScriptTask {
|
|||
url.clone()
|
||||
});
|
||||
debug!("ScriptTask: current url is {:?}", base_url);
|
||||
let url = parse_url(href.Value(), base_url);
|
||||
let url = parse_url(href.value_ref(), base_url);
|
||||
|
||||
if click_frag {
|
||||
match self.find_fragment_node(page, url.fragment.unwrap()) {
|
||||
|
|
|
@ -91,7 +91,7 @@ mod parse_url_tests {
|
|||
|
||||
#[test]
|
||||
fn should_create_absolute_file_url_if_base_url_is_none_and_str_url_looks_filey() {
|
||||
let file = ~"local.html";
|
||||
let file = "local.html";
|
||||
let url = parse_url(file, None);
|
||||
debug!("url: {:?}", url);
|
||||
assert!(url.scheme == ~"file");
|
||||
|
@ -102,9 +102,9 @@ mod parse_url_tests {
|
|||
|
||||
#[test]
|
||||
fn should_create_url_based_on_old_url_1() {
|
||||
let old_str = ~"http://example.com";
|
||||
let old_str = "http://example.com";
|
||||
let old_url = parse_url(old_str, None);
|
||||
let new_str = ~"index.html";
|
||||
let new_str = "index.html";
|
||||
let new_url = parse_url(new_str, Some(old_url));
|
||||
assert!(new_url.scheme == ~"http");
|
||||
assert!(new_url.host == ~"example.com");
|
||||
|
@ -113,9 +113,9 @@ mod parse_url_tests {
|
|||
|
||||
#[test]
|
||||
fn should_create_url_based_on_old_url_2() {
|
||||
let old_str = ~"http://example.com/";
|
||||
let old_str = "http://example.com/";
|
||||
let old_url = parse_url(old_str, None);
|
||||
let new_str = ~"index.html";
|
||||
let new_str = "index.html";
|
||||
let new_url = parse_url(new_str, Some(old_url));
|
||||
assert!(new_url.scheme == ~"http");
|
||||
assert!(new_url.host == ~"example.com");
|
||||
|
@ -124,9 +124,9 @@ mod parse_url_tests {
|
|||
|
||||
#[test]
|
||||
fn should_create_url_based_on_old_url_3() {
|
||||
let old_str = ~"http://example.com/index.html";
|
||||
let old_str = "http://example.com/index.html";
|
||||
let old_url = parse_url(old_str, None);
|
||||
let new_str = ~"crumpet.html";
|
||||
let new_str = "crumpet.html";
|
||||
let new_url = parse_url(new_str, Some(old_url));
|
||||
assert!(new_url.scheme == ~"http");
|
||||
assert!(new_url.host == ~"example.com");
|
||||
|
@ -135,9 +135,9 @@ mod parse_url_tests {
|
|||
|
||||
#[test]
|
||||
fn should_create_url_based_on_old_url_4() {
|
||||
let old_str = ~"http://example.com/snarf/index.html";
|
||||
let old_str = "http://example.com/snarf/index.html";
|
||||
let old_url = parse_url(old_str, None);
|
||||
let new_str = ~"crumpet.html";
|
||||
let new_str = "crumpet.html";
|
||||
let new_url = parse_url(new_str, Some(old_url));
|
||||
assert!(new_url.scheme == ~"http");
|
||||
assert!(new_url.host == ~"example.com");
|
||||
|
@ -146,9 +146,9 @@ mod parse_url_tests {
|
|||
|
||||
#[test]
|
||||
fn should_create_url_based_on_old_url_5() {
|
||||
let old_str = ~"http://example.com/index.html";
|
||||
let old_str = "http://example.com/index.html";
|
||||
let old_url = parse_url(old_str, None);
|
||||
let new_str = ~"#top";
|
||||
let new_str = "#top";
|
||||
let new_url = parse_url(new_str, Some(old_url));
|
||||
|
||||
assert!(new_url.scheme == ~"http");
|
||||
|
@ -161,9 +161,9 @@ mod parse_url_tests {
|
|||
fn should_create_url_based_on_old_url_6() {
|
||||
use extra::url::UserInfo;
|
||||
|
||||
let old_str = ~"http://foo:bar@example.com:8080/index.html";
|
||||
let old_str = "http://foo:bar@example.com:8080/index.html";
|
||||
let old_url = parse_url(old_str, None);
|
||||
let new_str = ~"#top";
|
||||
let new_str = "#top";
|
||||
let new_url = parse_url(new_str, Some(old_url));
|
||||
|
||||
assert!(new_url.scheme == ~"http");
|
||||
|
@ -176,9 +176,9 @@ mod parse_url_tests {
|
|||
|
||||
#[test]
|
||||
fn should_create_url_based_on_old_url_7() {
|
||||
let old_str = ~"https://example.com/snarf/index.html";
|
||||
let old_str = "https://example.com/snarf/index.html";
|
||||
let old_url = parse_url(old_str, None);
|
||||
let new_str = ~"//example.com/crumpet.html";
|
||||
let new_str = "//example.com/crumpet.html";
|
||||
let new_url = parse_url(new_str, Some(old_url));
|
||||
assert!(new_url.scheme == ~"https");
|
||||
assert!(new_url.host == ~"example.com");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue