aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-02-12 12:50:26 +0100
committerBjörn Gustavsson <[email protected]>2015-02-12 13:14:38 +0100
commit49b07e561b3658f510ec6ab63cbe35fac24da97e (patch)
tree5100328a9eb421cd0048d5030b07ce6c285ff3de /lib
parent649d6e73294c3abc056235faba428c1033deb996 (diff)
downloadotp-49b07e561b3658f510ec6ab63cbe35fac24da97e.tar.gz
otp-49b07e561b3658f510ec6ab63cbe35fac24da97e.tar.bz2
otp-49b07e561b3658f510ec6ab63cbe35fac24da97e.zip
v3_core: Simplify translation of maps
There is no need to always introduce a new variable to hold a map. Maps are novars (constructs that don't export variables).
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/src/v3_core.erl12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl
index 7ab14cfffa..9dd6b319a3 100644
--- a/lib/compiler/src/v3_core.erl
+++ b/lib/compiler/src/v3_core.erl
@@ -66,6 +66,7 @@
%% match arguments are novars
%% case arguments are novars
%% receive timeouts are novars
+%% binaries and maps are novars
%% let/set arguments are expressions
%% fun is not a safe
@@ -783,15 +784,9 @@ expr_map(M0,Es0,A,St0) ->
false -> throw({bad_map,bad_map})
end.
-map_build_pairs(Map0, Es0, Ann, St0) ->
+map_build_pairs(Map, Es0, Ann, St0) ->
{Es,Pre,St1} = map_build_pairs_1(Es0, St0),
- case ann_c_map(Ann, Map0, Es) of
- #c_literal{}=Map ->
- {Map,[],St1};
- #c_map{}=Map ->
- {Var,St2} = new_var(St1),
- {Var,Pre++[#iset{var=Var,arg=Map}],St2}
- end.
+ {ann_c_map(Ann, Map, Es),Pre,St1}.
map_build_pairs_1([{Op0,L,K0,V0}|Es], St0) ->
{K,Pre0,St1} = safe(K0, St0),
@@ -1486,6 +1481,7 @@ force_novars(#iapply{}=App, St) -> {App,[],St};
force_novars(#icall{}=Call, St) -> {Call,[],St};
force_novars(#ifun{}=Fun, St) -> {Fun,[],St}; %These are novars too
force_novars(#ibinary{}=Bin, St) -> {Bin,[],St};
+force_novars(#c_map{}=Bin, St) -> {Bin,[],St};
force_novars(Ce, St) ->
force_safe(Ce, St).