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:
1 parent
a587ddc5a3
commit
edbc1da809
2 files changed
+2
-10
No files matched your search
+2
-2
@@ -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
|
||||
|
||||
@@ -358,10 +358,6 @@ null
|
||||
[1,2,3]
|
||||
[1,3,6]
|
||||
|
||||
[foreach range(5) as $x (0; .+$x | select($x!=2); [$x,.])]
|
||||
null
|
||||
[[0,0],[1,1],[3,4],[4,8]]
|
||||
|
||||
[limit(3; .[])]
|
||||
[11,22,33,44,55,66,77,88,99]
|
||||
[11,22,33]
|
||||
@@ -920,10 +916,6 @@ reduce . as $n (.; .)
|
||||
null
|
||||
null
|
||||
|
||||
reduce range(5) as $x (0; .+$x | select($x!=2))
|
||||
null
|
||||
8
|
||||
|
||||
# Destructuring
|
||||
. as {$a, b: [$c, {$d}]} | [$a, $c, $d]
|
||||
{"a":1, "b":[2,{"d":3}]}
|
||||
|
||||
Reference in new issue
Block a user