Don't unnecessarily clone strings

This commit is contained in:
Sam Gibson 2015-07-08 18:26:10 +12:00
parent 865fb2eacb
commit a068a80619

View file

@ -267,21 +267,21 @@ impl HSTSList {
})
}
fn has_domain(&self, host: String) -> bool {
fn has_domain(&self, host: &str) -> bool {
self.entries.iter().any(|e| {
e.matches_domain(&host)
})
}
fn has_subdomain(&self, host: String) -> bool {
fn has_subdomain(&self, host: &str) -> bool {
self.entries.iter().any(|e| {
e.matches_subdomain(&host)
e.matches_subdomain(host)
})
}
pub fn push(&mut self, entry: HSTSEntry) {
let have_domain = self.has_domain(entry.host.clone());
let have_subdomain = self.has_subdomain(entry.host.clone());
let have_domain = self.has_domain(&entry.host);
let have_subdomain = self.has_subdomain(&entry.host);
if !have_domain && !have_subdomain {
self.entries.push(entry);