From 46eec93773477d1643fc7b672da167b17a1961ff Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Tue, 23 Mar 2021 12:59:49 -0400 Subject: [PATCH] inline --- src/cache.rs | 2 ++ src/routes.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/cache.rs b/src/cache.rs index 5f21a1f..41ce24c 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -28,6 +28,7 @@ pub struct CachedImage { } impl CachedImage { + #[inline] fn len(&self) -> usize { self.data.capacity() + self @@ -47,6 +48,7 @@ impl CachedImage { .unwrap_or_default() } + #[inline] fn shrink_to_fit(&mut self) { self.data.shrink_to_fit(); self.content_length.as_mut().map(Vec::shrink_to_fit); diff --git a/src/routes.rs b/src/routes.rs index 85583b6..7698bdd 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -37,6 +37,7 @@ enum ServerResponse { } impl Responder for ServerResponse { + #[inline] fn respond_to(self, req: &HttpRequest) -> HttpResponse { match self { Self::TokenValidationError(e) => e.respond_to(req), @@ -111,6 +112,7 @@ enum TokenValidationError { } impl Responder for TokenValidationError { + #[inline] fn respond_to(self, _: &HttpRequest) -> HttpResponse { push_headers(&mut HttpResponse::Forbidden()).finish() } @@ -150,6 +152,7 @@ fn validate_token( Ok(()) } +#[inline] fn push_headers(builder: &mut HttpResponseBuilder) -> &mut HttpResponseBuilder { builder .insert_header((X_CONTENT_TYPE_OPTIONS, "nosniff"))