Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiny performance optimization and refactoring #226

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/jar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl CookieJar {
/// assert!(matches!(jar.prefixed(Secure).get("h0st"), None));
/// ```
#[inline(always)]
pub fn prefixed<'a, P: Prefix>(&'a self, prefix: P) -> PrefixedJar<P, &'a Self> {
pub fn prefixed<P: Prefix>(&self, prefix: P) -> PrefixedJar<P, &Self> {
let _ = prefix;
PrefixedJar::new(self)
}
Expand Down Expand Up @@ -580,7 +580,7 @@ impl CookieJar {
/// jar.prefixed_mut(Host).remove("one");
/// assert!(jar.prefixed(Host).get("one").is_none());
/// ```
pub fn prefixed_mut<'a, P: Prefix>(&'a mut self, prefix: P) -> PrefixedJar<P, &'a mut Self> {
pub fn prefixed_mut<P: Prefix>(&mut self, prefix: P) -> PrefixedJar<P, &mut Self> {
let _ = prefix;
PrefixedJar::new(self)
}
Expand Down Expand Up @@ -616,7 +616,7 @@ impl<'a> Iterator for Iter<'a> {
fn next(&mut self) -> Option<&'a Cookie<'static>> {
for cookie in self.delta_cookies.by_ref() {
if !cookie.removed {
return Some(&*cookie);
return Some(&**cookie);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ impl<'c> Cookie<'c> {
match self.domain {
Some(ref c) => {
let domain = c.to_str(self.cookie_string.as_ref());
domain.strip_prefix(".").or(Some(domain))
domain.strip_prefix('.').or(Some(domain))
},
None => None,
}
Expand Down Expand Up @@ -1362,7 +1362,7 @@ impl<'c> Cookie<'c> {
pub fn domain_raw(&self) -> Option<&'c str> {
match (self.domain.as_ref(), self.cookie_string.as_ref()) {
(Some(domain), Some(string)) => match domain.to_raw_str(string) {
Some(s) => s.strip_prefix(".").or(Some(s)),
Some(s) => s.strip_prefix('.').or(Some(s)),
None => None,
}
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn parse_inner<'c>(s: &str, decode: bool) -> Result<Cookie<'c>, ParseError> {
v = &v[1..];
}

if !v.chars().all(|d| d.is_digit(10)) {
if !v.chars().all(|d| d.is_ascii_digit()) {
continue
}

Expand Down