Repository: dotnet/runtime
File: src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs (C#)

Code before:
        /// Determines a character's membership in a character class (via the string representation of the class).
        /// </summary>
        public static bool CharInClass(char ch, string set) =>
            CharInClassIterative(ch, set, 0);

        private static bool CharInClassIterative(char ch, string set, int start)
        {
            bool inClass = false;

            while (true)
            {
                int setLength = set[start + SetLengthIndex];
                int categoryLength = set[start + CategoryLengthIndex];
                int endPosition = start + SetStartIndex + setLength + categoryLength;

                bool inThisLevel = CharInClassInternal(ch, set, start, setLength, categoryLength);

                if (IsNegated(set, start))
                {
                    inThisLevel = !inThisLevel;
                }

                if (!inThisLevel)
                {
                    break;
                }

                inClass = !inClass;

                if (set.Length <= endPosition)
                {
                    break;
                }

                start = endPosition;
            }

            return inClass;
        }

        /// <summary>
        /// Determines a character's membership in a character class (via the
        /// string representation of the class).
        /// </summary>
        private static bool CharInClassInternal(char ch, string set, int start, int setLength, int categoryLength)
        {
            int min = start + SetStartIndex;
            int max = min + setLength;

            while (min != max)
            {

Review comment (suggestion):
This is more simply just:
```csharp
if (CharInClassInternal(ch, set, start, setLength, categoryLength) == IsNegated(set, start))
{
    break;
}
```

Code after:
        /// Determines a character's membership in a character class (via the string representation of the class).
        /// </summary>
        public static bool CharInClass(char ch, string set) =>
            CharInClassIterative(ch, set, 0);

        private static bool CharInClassIterative(char ch, string set, int start)
        {
            bool inClass = false;

            while (true)
            {
                int setLength = set[start + SetLengthIndex];
                int categoryLength = set[start + CategoryLengthIndex];
                int endPosition = start + SetStartIndex + setLength + categoryLength;

                if (CharInClassInternal(ch, set, start, setLength, categoryLength) == IsNegated(set, start))
                {
                    break;
                }

                inClass = !inClass;

                if (set.Length <= endPosition)
                {
                    break;
                }

                start = endPosition;
            }

            return inClass;
        }

        /// <summary>
        /// Determines a character's membership in a character class (via the
        /// string representation of the class).
        /// </summary>
        private static bool CharInClassInternal(char ch, string set, int start, int setLength, int categoryLength)
        {
            int min = start + SetStartIndex;
            int max = min + setLength;

            while (min != max)
            {
                int mid = (min + max) >> 1;
                if (ch < set[mid])
                {
                    max = mid;
                }
                else
                {