1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 08:22:59 +01:00

use small vec on hot path

This commit is contained in:
Nikolay Kim 2018-03-09 08:00:44 -08:00
parent c33caddf57
commit e2107ec6f4

View File

@ -1,6 +1,7 @@
use std::rc::Rc; use std::rc::Rc;
use std::marker::PhantomData; use std::marker::PhantomData;
use smallvec::SmallVec;
use http::{Method, StatusCode}; use http::{Method, StatusCode};
use pred; use pred;
@ -34,7 +35,7 @@ use httpresponse::HttpResponse;
pub struct Resource<S=()> { pub struct Resource<S=()> {
name: String, name: String,
state: PhantomData<S>, state: PhantomData<S>,
routes: Vec<Route<S>>, routes: SmallVec<[Route<S>; 3]>,
middlewares: Rc<Vec<Box<Middleware<S>>>>, middlewares: Rc<Vec<Box<Middleware<S>>>>,
} }
@ -43,7 +44,7 @@ impl<S> Default for Resource<S> {
Resource { Resource {
name: String::new(), name: String::new(),
state: PhantomData, state: PhantomData,
routes: Vec::new(), routes: SmallVec::new(),
middlewares: Rc::new(Vec::new()) } middlewares: Rc::new(Vec::new()) }
} }
} }
@ -54,7 +55,7 @@ impl<S> Resource<S> {
Resource { Resource {
name: String::new(), name: String::new(),
state: PhantomData, state: PhantomData,
routes: Vec::new(), routes: SmallVec::new(),
middlewares: Rc::new(Vec::new()) } middlewares: Rc::new(Vec::new()) }
} }