Skip to content

Commit 406a7d9

Browse files
Copilotstephentoub
andcommitted
Fix comment to accurately describe non-atomic alternation support
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
1 parent cca1612 commit 406a7d9

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Emitter.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,9 +1992,11 @@ void EmitSwitchedBranches()
19921992
break;
19931993
}
19941994

1995-
// This is only ever used for atomic alternations, so we can simply reset the doneLabel
1996-
// after emitting the child, as nothing will backtrack here (and we need to reset it
1997-
// so that all branches see the original).
1995+
// This is only ever used for alternations where no branch may backtrack
1996+
// (whether due to being atomic or simply because nothing in the branch
1997+
// can backtrack), so we can simply reset the doneLabel after emitting the
1998+
// child, as nothing will backtrack here (and we need to reset it so that
1999+
// all branches see the original).
19982000
doneLabel = originalDoneLabel;
19992001

20002002
// If we get here in the generated code, the branch completed successfully.

src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,9 +2096,11 @@ void EmitSwitchedBranches(RegexNode node, int childCount, int minValue, int rang
20962096
break;
20972097
}
20982098

2099-
// This is only ever used for atomic alternations, so we can simply reset the doneLabel
2100-
// after emitting the child, as nothing will backtrack here (and we need to reset it
2101-
// so that all branches see the original).
2099+
// This is only ever used for alternations where no branch may backtrack
2100+
// (whether due to being atomic or simply because nothing in the branch
2101+
// can backtrack), so we can simply reset the doneLabel after emitting the
2102+
// child, as nothing will backtrack here (and we need to reset it so that
2103+
// all branches see the original).
21022104
doneLabel = originalDoneLabel;
21032105

21042106
// If we get here in the generated code, the branch completed successfully.

0 commit comments

Comments
 (0)