From c0bb7f866257168e0a05110767fc7096a93d351d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 3 Oct 2013 13:22:32 +0200 Subject: sys_core_fold: Remove optimization that has become invalid With the => and := operators for updating maps, this optimization is no longer valid. --- lib/compiler/src/sys_core_fold.erl | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'lib/compiler/src/sys_core_fold.erl') diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl index 2cd6ea0e53..6792e2c894 100644 --- a/lib/compiler/src/sys_core_fold.erl +++ b/lib/compiler/src/sys_core_fold.erl @@ -418,35 +418,8 @@ expr(#c_try{anno=A,arg=E0,vars=Vs0,body=B0,evars=Evs0,handler=H0}=Try, _, Sub0) expr_list(Es, Ctxt, Sub) -> [expr(E, Ctxt, Sub) || E <- Es]. -%% traverse pairs in reverse -%% - remove later literals since they will be overwritten. - pair_list(Es, Ctxt, Sub) -> - pair_list_reversed(lists:reverse(Es), Ctxt, Sub, [], gb_sets:empty()). - -pair_list_reversed([],_,_,Es,_) -> Es; -pair_list_reversed([E|Es],Ctxt,Sub,Out,Keys) -> - Pair = pair(E,Ctxt,Sub), - case map_has_key(Pair,Keys) of - {false,Keys1} -> - pair_list_reversed(Es,Ctxt,Sub,[Pair|Out],Keys1); - {true,K} -> - add_warning(E, {map_pair_key_overloaded,K}), - pair_list_reversed(Es,Ctxt,Sub,Out,Keys) - end. - -%% check if key already is present in map, i.e. #{ a=>1, a=>2 } -%% where 'a' is duplicate. Update maps set with the key if not present. - -map_has_key(MapPair,Ks) -> - K = map_get_literal_key_from_pair(MapPair), - case gb_sets:is_element(K,Ks) of - false -> {false, gb_sets:add(K,Ks)}; - true -> {true, K} - end. - -map_get_literal_key_from_pair(#c_map_pair_assoc{key=#c_literal{val=K}}) -> K; -map_get_literal_key_from_pair(#c_map_pair_exact{key=#c_literal{val=K}}) -> K. + [pair(E, Ctxt, Sub) || E <- Es]. pair(#c_map_pair_assoc{key=K,val=V}, effect, Sub) -> make_effect_seq([K,V], Sub); -- cgit v1.2.3