From fa967409232c06c35fb100aac65ff274d4d6c30d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sat, 5 Jan 2013 19:33:37 -0800 Subject: librustc: Remove some string allocations. rs=perf --- src/libsyntax/attr.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 5062cefc497..73c14e2d00c 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -178,15 +178,15 @@ fn get_name_value_str_pair(item: @ast::meta_item) -> Option<(~str, ~str)> { /* Searching */ /// Search a list of attributes and return only those with a specific name -fn find_attrs_by_name(attrs: ~[ast::attribute], name: ~str) -> +fn find_attrs_by_name(attrs: ~[ast::attribute], name: &str) -> ~[ast::attribute] { - let filter = ( - fn@(a: &ast::attribute) -> Option { - if get_attr_name(*a) == name { - option::Some(*a) - } else { option::None } + let filter: &fn(a: &ast::attribute) -> Option = |a| { + if name == get_attr_name(*a) { + option::Some(*a) + } else { + option::None } - ); + }; return vec::filter_map(attrs, filter); } -- cgit 1.4.1-3-g733a5