Avoid calling to_vec() unnecessarily in parser.

Also, rename the OptVec-to-vector conversion method to
opt_vec::take_vec() and convert from a method into a fn
because I fear strange bugs.
This commit is contained in:
Niko Matsakis 2013-03-01 19:38:39 -05:00
parent 50c08dbf0d
commit ca9549bdfc
5 changed files with 28 additions and 18 deletions

View file

@ -460,8 +460,8 @@ fn mk_impl(
let ty = cx.ty_path(
span,
~[ident],
generics.ty_params.map(
|tp| cx.ty_path(span, ~[tp.ident], ~[])).to_vec()
opt_vec::take_vec(generics.ty_params.map(
|tp| cx.ty_path(span, ~[tp.ident], ~[])))
);
let generics = ast::Generics {

View file

@ -394,13 +394,15 @@ impl ext_ctxt_ast_builder for ext_ctxt {
}
fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[@ast::Ty] {
ty_params.map(|p| self.ty_path_ast_builder(
path(~[p.ident], dummy_sp()))).to_vec()
opt_vec::take_vec(
ty_params.map(|p| self.ty_path_ast_builder(
path(~[p.ident], dummy_sp()))))
}
fn ty_vars_global(&self,
ty_params: &OptVec<ast::TyParam>) -> ~[@ast::Ty] {
ty_params.map(|p| self.ty_path_ast_builder(
path(~[p.ident], dummy_sp()))).to_vec()
opt_vec::take_vec(
ty_params.map(|p| self.ty_path_ast_builder(
path(~[p.ident], dummy_sp()))))
}
}