mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-05-01 10:30:26 +00:00
fqdn comparison: make more efficient
Compare lazily to always avoid to vector collections and if one of the first parts mismatch some lower_case calls. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
9466865843
commit
573e3f41fb
@ -258,22 +258,17 @@ impl<'de> Deserialize<'de> for Fqdn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for Fqdn {
|
impl PartialEq for Fqdn {
|
||||||
|
// Case-insensitive comparison, as per RFC 952 "ASSUMPTIONS", RFC 1035 sec. 2.3.3. "Character
|
||||||
|
// Case" and RFC 4343 as a whole
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
// Case-insensitive comparison, as per RFC 952 "ASSUMPTIONS",
|
if self.parts.len() != other.parts.len() {
|
||||||
// RFC 1035 sec. 2.3.3. "Character Case" and RFC 4343 as a whole
|
return false;
|
||||||
let a = self
|
}
|
||||||
.parts
|
|
||||||
.iter()
|
|
||||||
.map(|s| s.to_lowercase())
|
|
||||||
.collect::<Vec<String>>();
|
|
||||||
|
|
||||||
let b = other
|
self.parts
|
||||||
.parts
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| s.to_lowercase())
|
.zip(other.parts.iter())
|
||||||
.collect::<Vec<String>>();
|
.all(|(a, b)| a.to_lowercase() == b.to_lowercase())
|
||||||
|
|
||||||
a == b
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user