cleanup redundant tail code

This commit is contained in:
Rob Ede 2021-07-19 20:31:43 +01:00
parent adf4867f28
commit 5ddbccd07e
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
3 changed files with 6 additions and 16 deletions

View File

@ -6,7 +6,8 @@
* Path tail pattern now works as expected after a dynamic segment (e.g. `/user/{uid}/*`). [#366]
* Fix a bug in multi-patterns where static patterns are interpreted as regex. [#366]
* Fix `ResourceDef` `PartialEq` implementation.
* Re-work `IntoPatterns` trait. [#372]
* Re-work `IntoPatterns` trait, adding a `Patterns` enum. [#372]
* Implement `IntoPatterns` for `bytestring::ByteString`. [#372]
* Rename `Path::{len => segment_count}` to be more descriptive of it's purpose. [#370]
* Rename `ResourceDef::{resource_path => resource_path_from_iter}`. [#371]
* Rename `ResourceDef::{resource_path_named => resource_path_from_map}`. [#371]

View File

@ -26,7 +26,6 @@ pub struct Path<T> {
path: T,
pub(crate) skip: u16,
pub(crate) segments: Vec<(Cow<'static, str>, PathItem)>,
pub(crate) tail: Option<PathItem>,
}
impl<T: ResourcePath> Path<T> {
@ -35,7 +34,6 @@ impl<T: ResourcePath> Path<T> {
path,
skip: 0,
segments: Vec::new(),
tail: None,
}
}
@ -98,11 +96,6 @@ impl<T: ResourcePath> Path<T> {
}
}
pub(crate) fn add_tail(&mut self, value: PathItem) {
profile_method!(add_tail);
self.tail = Some(value);
}
#[doc(hidden)]
pub fn add_static(
&mut self,

View File

@ -717,12 +717,12 @@ impl ResourceDef {
let path = resource.resource_path();
let path_str = path.path();
let (matched_len, matched_vars, tail) = match &self.pat_type {
let (matched_len, matched_vars) = match &self.pat_type {
PatternType::Static(_) | PatternType::Prefix(_) => {
profile_section!(pattern_static_or_prefix);
match self.find_match(path_str) {
Some(len) => (len, None, None),
Some(len) => (len, None),
None => return false,
}
}
@ -755,7 +755,7 @@ impl ResourceDef {
}
};
(captures[0].len(), Some(names), None)
(captures[0].len(), Some(names))
}
PatternType::DynamicSet(re, params) => {
@ -781,7 +781,7 @@ impl ResourceDef {
}
}
(captures[0].len(), Some(names), None)
(captures[0].len(), Some(names))
}
};
@ -798,10 +798,6 @@ impl ResourceDef {
}
}
if let Some(tail) = tail {
path.add_tail(tail)
}
path.skip(matched_len as u16);
true