Revert "fix: reduce/foreach state variable should not be reset each iteration" (#3349)

This reverts 96e8d893c1. The change
introduced a serious performance regression as reported in #3345.
This commit is contained in:
itchyny authored and GitHub committed 2025-06-17 15:29:46 +09:00
1 parent a587ddc5a3
commit edbc1da809
2 files changed
+2 -10

No files matched your search

+2 -2
View File
@@ -831,7 +831,7 @@ block gen_reduce(block source, block matcher, block init, block body) {
block loop = BLOCK(gen_op_simple(DUPN),
source,
bind_alternation_matchers(matcher,
BLOCK(gen_op_bound(LOADV, res_var),
BLOCK(gen_op_bound(LOADVN, res_var),
body,
gen_op_bound(STOREV, res_var))),
gen_op_simple(BACKTRACK));
@@ -855,7 +855,7 @@ block gen_foreach(block source, block matcher, block init, block update, block e
// in the body to see
bind_alternation_matchers(matcher,
// load the loop state variable
BLOCK(gen_op_bound(LOADV, state_var),
BLOCK(gen_op_bound(LOADVN, state_var),
// generate updated state
update,
// save the updated state for value extraction