aboutsummaryrefslogtreecommitdiffstats
path: root/enumerator.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-10 10:26:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-10 10:26:32 +0000
commit45140f69b0b3f63108b64d97001566b26fc40842 (patch)
tree0ce984c861b72dd4a833fb166f1b85c6c45a7cb2 /enumerator.c
parent008d621e7d53f76e25e456307124bd087ed91b53 (diff)
downloadruby-45140f69b0b3f63108b64d97001566b26fc40842.tar.gz
enumerator.c: fix nested maps
* enumerator.c (lazy_map_proc, lazy_grep_iter_proc): marks values returned by blocks are not packed in the case of nested maps, so that the result will be same as non-lazy version. based on the patch by akihikodaki (Akihiko Odaki) at [ruby-core:81638], without GCC extension. [Bug#13648] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/enumerator.c b/enumerator.c
index 9de08d7d2a..a996566b7b 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -1448,6 +1448,8 @@ lazy_init_block_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
#define LAZY_MEMO_PACKED_P(memo) ((memo)->memo_flags & LAZY_MEMO_PACKED)
#define LAZY_MEMO_SET_BREAK(memo) ((memo)->memo_flags |= LAZY_MEMO_BREAK)
#define LAZY_MEMO_SET_VALUE(memo, value) MEMO_V2_SET(memo, value)
+#define LAZY_MEMO_SET_PACKED(memo) ((memo)->memo_flags |= LAZY_MEMO_PACKED)
+#define LAZY_MEMO_RESET_PACKED(memo) ((memo)->memo_flags &= ~LAZY_MEMO_PACKED)
static VALUE
lazy_init_yielder(VALUE val, VALUE m, int argc, VALUE *argv)
@@ -1743,6 +1745,7 @@ lazy_map_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long memo_inde
{
VALUE value = lazyenum_yield_values(proc_entry, result);
LAZY_MEMO_SET_VALUE(result, value);
+ LAZY_MEMO_RESET_PACKED(result);
return result;
}
@@ -1913,6 +1916,7 @@ lazy_grep_iter_proc(VALUE proc_entry, struct MEMO *result, VALUE memos, long mem
if (!RTEST(chain)) return 0;
value = rb_proc_call_with_block(entry->proc, 1, &(result->memo_value), Qnil);
LAZY_MEMO_SET_VALUE(result, value);
+ LAZY_MEMO_RESET_PACKED(result);
return result;
}