From e2107ec6f445e2653a574da0394b9d39e4ba52c8 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 9 Mar 2018 08:00:44 -0800 Subject: [PATCH] use small vec on hot path --- src/resource.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/resource.rs b/src/resource.rs index 2e83225e..3d8c4b98 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -1,6 +1,7 @@ use std::rc::Rc; use std::marker::PhantomData; +use smallvec::SmallVec; use http::{Method, StatusCode}; use pred; @@ -34,7 +35,7 @@ use httpresponse::HttpResponse; pub struct Resource { name: String, state: PhantomData, - routes: Vec>, + routes: SmallVec<[Route; 3]>, middlewares: Rc>>>, } @@ -43,7 +44,7 @@ impl Default for Resource { Resource { name: String::new(), state: PhantomData, - routes: Vec::new(), + routes: SmallVec::new(), middlewares: Rc::new(Vec::new()) } } } @@ -54,7 +55,7 @@ impl Resource { Resource { name: String::new(), state: PhantomData, - routes: Vec::new(), + routes: SmallVec::new(), middlewares: Rc::new(Vec::new()) } }