aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-01-14 18:13:45 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-01-29 11:08:46 +0100
commit00f9be42e43913bce9b110382e55bfbdaa9406d0 (patch)
tree33d6d0ea665e1318c867dac24fc6f71bc4faa0e4 /erts/emulator/beam/erl_nif.c
parentada36d9024b4ceda974f32a78b5fe39b64f59319 (diff)
downloadotp-00f9be42e43913bce9b110382e55bfbdaa9406d0.tar.gz
otp-00f9be42e43913bce9b110382e55bfbdaa9406d0.tar.bz2
otp-00f9be42e43913bce9b110382e55bfbdaa9406d0.zip
erts: Fix map iterator bug when reverting from end of map position
and simplify code by ignoring h_limit which is always zero.
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r--erts/emulator/beam/erl_nif.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index c6f7c8adb5..6fceb8a0ba 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -1759,13 +1759,10 @@ int enif_map_iterator_next(ErlNifEnv *env, ErlNifMapIterator *iter)
ASSERT(iter && is_map(iter->map));
if (iter->idx < iter->t_limit) {
iter->idx++;
- if (iter->idx != iter->t_limit) {
- iter->ks++;
- iter->vs++;
- return 1;
- }
+ iter->ks++;
+ iter->vs++;
}
- return 0;
+ return (iter->idx != iter->t_limit);
}
int enif_map_iterator_prev(ErlNifEnv *env, ErlNifMapIterator *iter)
@@ -1773,13 +1770,10 @@ int enif_map_iterator_prev(ErlNifEnv *env, ErlNifMapIterator *iter)
ASSERT(iter && is_map(iter->map));
if (iter->idx > 0) {
iter->idx--;
- if (iter->idx != 0) {
- iter->ks--;
- iter->vs--;
- return 1;
- }
+ iter->ks--;
+ iter->vs--;
}
- return 0;
+ return (iter->idx > 0);
}
int enif_map_iterator_get_pair(ErlNifEnv *env,