From 5ddbccd07e7e22345f47cb61032534aecf36f21a Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 19 Jul 2021 20:31:43 +0100 Subject: [PATCH] cleanup redundant tail code --- actix-router/CHANGES.md | 3 ++- actix-router/src/path.rs | 7 ------- actix-router/src/resource.rs | 12 ++++-------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/actix-router/CHANGES.md b/actix-router/CHANGES.md index f2eee276..4e5753e7 100644 --- a/actix-router/CHANGES.md +++ b/actix-router/CHANGES.md @@ -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] diff --git a/actix-router/src/path.rs b/actix-router/src/path.rs index 565dbd79..e29591f9 100644 --- a/actix-router/src/path.rs +++ b/actix-router/src/path.rs @@ -26,7 +26,6 @@ pub struct Path { path: T, pub(crate) skip: u16, pub(crate) segments: Vec<(Cow<'static, str>, PathItem)>, - pub(crate) tail: Option, } impl Path { @@ -35,7 +34,6 @@ impl Path { path, skip: 0, segments: Vec::new(), - tail: None, } } @@ -98,11 +96,6 @@ impl Path { } } - 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, diff --git a/actix-router/src/resource.rs b/actix-router/src/resource.rs index 01939d7c..5edf0d0c 100644 --- a/actix-router/src/resource.rs +++ b/actix-router/src/resource.rs @@ -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