refactor(readability): and reducing condition evaluation twice on same condition

This commit is contained in:
M.Schmidt
2026-07-12 21:04:37 +02:00
parent f017c700f1
commit 3cb12c6fc1
+13 -16
View File
@@ -401,19 +401,16 @@ impl WebDavAdapter {
/// `quota-used-bytes` known but `quota-available-bytes` unknown (see /// `quota-used-bytes` known but `quota-available-bytes` unknown (see
/// `resolve_quota` in `webdav_handler.rs`). /// `resolve_quota` in `webdav_handler.rs`).
fn folder_prop_is_known(prop: &QualifiedName, quota: Option<(i64, Option<i64>)>) -> bool { fn folder_prop_is_known(prop: &QualifiedName, quota: Option<(i64, Option<i64>)>) -> bool {
prop.namespace == "DAV:" if prop.namespace != "DAV:" {
&& (matches!( return false;
prop.name.as_str(), }
"resourcetype" match prop.name.as_str() {
| "displayname" "resourcetype" | "displayname" | "creationdate" | "getlastmodified" | "getetag"
| "creationdate" | "getcontentlength" | "getcontenttype" => true,
| "getlastmodified" "quota-used-bytes" => quota.is_some(),
| "getetag" "quota-available-bytes" => quota.is_some_and(|(_, available)| available.is_some()),
| "getcontentlength" _ => false,
| "getcontenttype" }
) || (quota.is_some() && prop.name == "quota-used-bytes")
|| (quota.is_some_and(|(_, available)| available.is_some())
&& prop.name == "quota-available-bytes"))
} }
fn file_prop_is_known(prop: &QualifiedName) -> bool { fn file_prop_is_known(prop: &QualifiedName) -> bool {
@@ -842,12 +839,12 @@ impl WebDavAdapter {
xml_writer.write_event(Event::Empty(BytesStart::new("D:getetag")))?; xml_writer.write_event(Event::Empty(BytesStart::new("D:getetag")))?;
xml_writer.write_event(Event::Empty(BytesStart::new("D:getcontentlength")))?; xml_writer.write_event(Event::Empty(BytesStart::new("D:getcontentlength")))?;
xml_writer.write_event(Event::Empty(BytesStart::new("D:getcontenttype")))?; xml_writer.write_event(Event::Empty(BytesStart::new("D:getcontenttype")))?;
if quota.is_some() { if let Some((_, available)) = quota {
xml_writer.write_event(Event::Empty(BytesStart::new("D:quota-used-bytes")))?; xml_writer.write_event(Event::Empty(BytesStart::new("D:quota-used-bytes")))?;
} if available.is_some() {
if quota.is_some_and(|(_, available)| available.is_some()) {
xml_writer.write_event(Event::Empty(BytesStart::new("D:quota-available-bytes")))?; xml_writer.write_event(Event::Empty(BytesStart::new("D:quota-available-bytes")))?;
} }
}
Ok(()) Ok(())
} }