[pbs-devel] [PATCH proxmox-backup 1/3] Userid: simplify comparison with str
Fabian Grünbichler
f.gruenbichler at proxmox.com
Thu Oct 8 15:37:18 CEST 2020
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
src/api2/types/userid.rs | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/api2/types/userid.rs b/src/api2/types/userid.rs
index 3001b1d9..f0a61031 100644
--- a/src/api2/types/userid.rs
+++ b/src/api2/types/userid.rs
@@ -397,10 +397,7 @@ impl TryFrom<String> for Userid {
impl PartialEq<str> for Userid {
fn eq(&self, rhs: &str) -> bool {
- rhs.len() > self.name_len + 2 // make sure range access below is allowed
- && rhs.starts_with(self.name().as_str())
- && rhs.as_bytes()[self.name_len] == b'@'
- && &rhs[(self.name_len + 1)..] == self.realm().as_str()
+ self.data == *rhs
}
}
--
2.20.1
More information about the pbs-devel
mailing list