[pbs-devel] [PATCH proxmox v2 01/15] ldap: avoid superfluous allocation when calling .search()
Christoph Heiss
c.heiss at proxmox.com
Wed Aug 16 16:47:31 CEST 2023
The `attrs` parameter of `Ldap::search()` is an `impl AsRef<[impl
AsRef<str>]>` anyway, so replace `vec![..]` with `&[..]`.
Suggested-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
Changes v1 -> v2:
* New patch
proxmox-ldap/src/lib.rs | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/proxmox-ldap/src/lib.rs b/proxmox-ldap/src/lib.rs
index b3b5d65..f9862e2 100644
--- a/proxmox-ldap/src/lib.rs
+++ b/proxmox-ldap/src/lib.rs
@@ -181,12 +181,7 @@ impl Connection {
// only search base to make sure the base_dn exists while avoiding most common size limits
let (_, _) = ldap
- .search(
- &self.config.base_dn,
- Scope::Base,
- "(objectClass=*)",
- vec!["*"],
- )
+ .search(&self.config.base_dn, Scope::Base, "(objectClass=*)", &["*"])
.await?
.success()
.context("Could not search LDAP realm, base_dn could be incorrect")?;
@@ -319,7 +314,7 @@ impl Connection {
let query = format!("(&({}={}))", self.config.user_attr, username);
let (entries, _res) = ldap
- .search(&self.config.base_dn, Scope::Subtree, &query, vec!["dn"])
+ .search(&self.config.base_dn, Scope::Subtree, &query, &["dn"])
.await?
.success()?;
--
2.41.0
More information about the pbs-devel
mailing list