remove unnecessary loop/allocations on CIDR range init

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-09-01 00:59:43 -04:00
parent 27bfb67d75
commit 60605e9579

View file

@ -76,12 +76,15 @@ impl crate::Service for Service {
// Experimental, partially supported room versions
let unstable_room_versions = vec![RoomVersionId::V2, RoomVersionId::V3, RoomVersionId::V4, RoomVersionId::V5];
let mut cidr_range_denylist = Vec::new();
for cidr in config.ip_range_denylist.clone() {
let cidr = IPAddress::parse(cidr).expect("valid cidr range");
trace!("Denied CIDR range: {:?}", cidr);
cidr_range_denylist.push(cidr);
}
let cidr_range_denylist: Vec<_> = config
.ip_range_denylist
.iter()
.map(|cidr| {
let cidr = IPAddress::parse(cidr).expect("valid cidr range");
trace!("Denied CIDR range: {:?}", cidr);
cidr
})
.collect();
let mut s = Self {
db,