From ca9549bdfc3dd969e9182d58038f90bbef026ded Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 1 Mar 2013 19:38:39 -0500 Subject: 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. --- src/libsyntax/ext/auto_encode.rs | 4 ++-- src/libsyntax/ext/pipes/ast_builder.rs | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index 5f076136271..b00fa9d0a19 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -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 { diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 3e6dedb3b31..6e1406e3647 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -394,13 +394,15 @@ impl ext_ctxt_ast_builder for ext_ctxt { } fn ty_vars(&self, ty_params: &OptVec) -> ~[@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::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())))) } } -- cgit 1.4.1-3-g733a5