Skip to content

Commit f4ea8f0

Browse files
authored
Refactor walk function to initialize x inside loop
1 parent f52bef2 commit f4ea8f0

File tree

1 file changed

+1
-2
lines changed
  • library/data_structures_[l,r)/seg_tree_uncommon

1 file changed

+1
-2
lines changed

library/data_structures_[l,r)/seg_tree_uncommon/walk.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
int walk(int l, int r, const auto& f) {
2-
T x = unit;
3-
while (l < r) {
2+
while (T x = unit; l < r) {
43
int u = l + n, v = __lg(min(u & -u, r - l));
54
if (T y = op(x, s[u >> v]); f(y)) x = y, l += 1 << v;
65
else r = l + (1 << v) - 1;

0 commit comments

Comments
 (0)