mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2024-12-27 03:16:33 +00:00
Clean up double if-lets with tuple matches
This commit is contained in:
parent
1b62208c78
commit
43d0578ab7
2 changed files with 11 additions and 16 deletions
|
@ -129,19 +129,16 @@ fn paths_match(ref_path: &str, req_path: &str) -> bool {
|
||||||
let mut ref_iter = ref_path.split('/');
|
let mut ref_iter = ref_path.split('/');
|
||||||
let mut req_iter = req_path.split('/');
|
let mut req_iter = req_path.split('/');
|
||||||
loop {
|
loop {
|
||||||
let ref_seg_opt = ref_iter.next();
|
match (ref_iter.next(), req_iter.next()) {
|
||||||
let req_seg_opt = req_iter.next();
|
(None, None) => return true,
|
||||||
if ref_seg_opt.is_none() != req_seg_opt.is_none() {
|
(Some(ref_seg), Some(req_seg)) => {
|
||||||
return false;
|
if ref_seg.starts_with('{') || ref_seg == req_seg {
|
||||||
}
|
continue;
|
||||||
if let Some(ref_seg) = ref_seg_opt {
|
}
|
||||||
if let Some(req_seg) = req_seg_opt {
|
return false;
|
||||||
if ref_seg.starts_with('{') || ref_seg == req_seg {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
return false;
|
_ => return false,
|
||||||
}}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,9 +169,7 @@ impl RateLimit {
|
||||||
let count_header_opt = headers.get(self.rate_limit_type.count_header())
|
let count_header_opt = headers.get(self.rate_limit_type.count_header())
|
||||||
.map(|h| h.to_str().expect("Failed to read count header as string."));
|
.map(|h| h.to_str().expect("Failed to read count header as string."));
|
||||||
|
|
||||||
// https://github.com/rust-lang/rust/issues/53667
|
if let (Some(limit_header), Some(count_header)) = (limit_header_opt, count_header_opt) {
|
||||||
if let Some(limit_header) = limit_header_opt {
|
|
||||||
if let Some(count_header) = count_header_opt {
|
|
||||||
{
|
{
|
||||||
let buckets = self.buckets.upgradable_read();
|
let buckets = self.buckets.upgradable_read();
|
||||||
if !buckets_require_updating(limit_header, &*buckets) {
|
if !buckets_require_updating(limit_header, &*buckets) {
|
||||||
|
@ -184,7 +182,7 @@ impl RateLimit {
|
||||||
}
|
}
|
||||||
// Notify waiters that buckets have updated (after unlocking).
|
// Notify waiters that buckets have updated (after unlocking).
|
||||||
self.update_notify.notify_waiters();
|
self.update_notify.notify_waiters();
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue