aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-05-12 17:18:28 +0200
committerMs2ger <ms2ger@gmail.com>2014-05-12 17:18:28 +0200
commit85ce33916cb105d8e82ef8011061ede37f54998a (patch)
tree294e84d8707822e22b5a621ad27c1cd3c076900a /src
parentb036bee532fafe3733eb3cb2ccad98fa85c23a92 (diff)
downloadservo-85ce33916cb105d8e82ef8011061ede37f54998a.tar.gz
servo-85ce33916cb105d8e82ef8011061ede37f54998a.zip
Avoid unnecessary allocations in try_parse_url.
Diffstat (limited to 'src')
-rw-r--r--src/components/util/url.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/components/util/url.rs b/src/components/util/url.rs
index 47c4043b330..da2ca64c0e0 100644
--- a/src/components/util/url.rs
+++ b/src/components/util/url.rs
@@ -18,7 +18,7 @@ Create a URL object from a string. Does various helpful browsery things like
*/
// TODO: about:failure->
pub fn try_parse_url(str_url: &str, base_url: Option<std_url::Url>) -> Result<std_url::Url, ~str> {
- let str_url = str_url.trim_chars(& &[' ', '\t', '\n', '\r', '\x0C']).to_owned();
+ let str_url = str_url.trim_chars(& &[' ', '\t', '\n', '\r', '\x0C']);
let schm = std_url::get_scheme(str_url);
let str_url = match schm {
Err(_) => {
@@ -69,7 +69,7 @@ pub fn try_parse_url(str_url: &str, base_url: Option<std_url::Url>) -> Result<st
"file://".to_owned() + path.display().to_str()
}
// TODO: handle the rest of the about: pages
- _ => str_url
+ _ => str_url.to_owned()
}
},
"data" => {
@@ -78,7 +78,7 @@ pub fn try_parse_url(str_url: &str, base_url: Option<std_url::Url>) -> Result<st
// %-encoded or base64'd.
str_url.chars().filter(|&c| !c.is_whitespace()).collect()
},
- _ => str_url
+ _ => str_url.to_owned()
}
}
};