aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2013-03-07 16:06:46 +0100
committerBjörn-Egil Dahlberg <[email protected]>2013-03-12 16:42:23 +0100
commit9b25088a6f1494d4ff6cd39653dba155d6639f5d (patch)
tree2ed77c455d8bfacf0465a8a04da8f10d788fa691 /erts/emulator/beam
parentcec7b1b3529dcc09298e01a243252045a0fb08bc (diff)
downloadotp-9b25088a6f1494d4ff6cd39653dba155d6639f5d.tar.gz
otp-9b25088a6f1494d4ff6cd39653dba155d6639f5d.tar.bz2
otp-9b25088a6f1494d4ff6cd39653dba155d6639f5d.zip
erts: Refactor erlang:insert_element/3 for clarity
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/bif.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index 923bc50c40..ff237b6a78 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -2543,7 +2543,7 @@ BIF_RETTYPE insert_element_3(BIF_ALIST_3)
Eterm* hp;
Uint arity;
Eterm res;
- Sint ix;
+ Sint ix, c1, c2;
if (is_not_tuple(BIF_ARG_2) || is_not_small(BIF_ARG_1)) {
BIF_ERROR(BIF_P, BADARG);
@@ -2561,14 +2561,12 @@ BIF_RETTYPE insert_element_3(BIF_ALIST_3)
res = make_tuple(hp);
*hp = make_arityval(arity + 1);
- ix--;
- arity -= ix;
-
- while (ix--) { *++hp = *++ptr; }
+ c1 = ix - 1;
+ c2 = arity - ix + 1;
+ while (c1--) { *++hp = *++ptr; }
*++hp = BIF_ARG_3;
-
- while(arity--) { *++hp = *++ptr; }
+ while (c2--) { *++hp = *++ptr; }
BIF_RET(res);
}