Skip to content

Commit 118a00c

Browse files
committed
refactor _count general case
1 parent f9b2d10 commit 118a00c

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

‎src/engine.rs‎

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,26 +1446,20 @@ fn _count<S: StrDrive>(
14461446
}
14471447
_ => {
14481448
/* General case */
1449-
let mut count = 0;
1450-
1451-
let mut sub_ctx = MatchContext {
1452-
toplevel: false,
1453-
jump: Jump::OpCode,
1454-
repeat_ctx_id: usize::MAX,
1455-
count: -1,
1456-
..ctx
1449+
ctx.toplevel = false;
1450+
ctx.jump = Jump::OpCode;
1451+
ctx.repeat_ctx_id = usize::MAX;
1452+
ctx.count = -1;
1453+
1454+
let mut sub_state = State {
1455+
marks: Marks::default(),
1456+
repeat_stack: vec![],
1457+
..*state
14571458
};
14581459

1459-
while count < max_count {
1460-
if !_match(req, state, sub_ctx) {
1461-
break;
1462-
}
1463-
count += 1;
1464-
sub_ctx.skip_char(req, 1);
1465-
// ctx.string_position = state.string_position;
1466-
// ctx.string_offset = req.string.offset(0, state.string_position);
1460+
while ctx.string_position < end && _match(req, &mut sub_state, ctx) {
1461+
ctx.skip_char(req, 1);
14671462
}
1468-
return count;
14691463
}
14701464
}
14711465

0 commit comments

Comments
 (0)