1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-24 16:02: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::marker::PhantomData;
use smallvec::SmallVec;
use http::{Method, StatusCode};
use pred;
@ -34,7 +35,7 @@ use httpresponse::HttpResponse;
pub struct Resource<S=()> {
name: String,
state: PhantomData<S>,
routes: Vec<Route<S>>,
routes: SmallVec<[Route<S>; 3]>,
middlewares: Rc<Vec<Box<Middleware<S>>>>,
}
@ -43,7 +44,7 @@ impl<S> Default for Resource<S> {
Resource {
name: String::new(),
state: PhantomData,
routes: Vec::new(),
routes: SmallVec::new(),
middlewares: Rc::new(Vec::new()) }
}
}
@ -54,7 +55,7 @@ impl<S> Resource<S> {
Resource {
name: String::new(),
state: PhantomData,
routes: Vec::new(),
routes: SmallVec::new(),
middlewares: Rc::new(Vec::new()) }
}