Repository: microsoft/terminal
File: src/terminal/parser/stateMachine.cpp (C++)

Code before:
#elif defined(TIL_ARM_NEON_INTRINSICS)

    auto it = data;
    uint64_t mask;

    for (const auto end = data + (count & ~size_t{ 7 }); it < end;)
    {
        const auto wch = vld1q_u16(it);
        const auto a = vcleq_u16(wch, vdupq_n_u16(0x1f));
        const auto b = vcleq_u16(vsubq_u16(wch, vdupq_n_u16(0x7f)), vdupq_n_u16(0x20));
        const auto c = vorrq_u16(a, b);

        mask = vgetq_lane_u64(c, 0);
        if (mask)
        {
            goto exitWithMask;
        }
        it += 4;

        mask = vgetq_lane_u64(c, 1);
        if (mask)
        {
            goto exitWithMask;
        }
        it += 4;
    }

    return findActionableFromGroundPlain(data, data + count, it);

exitWithMask:
    unsigned long offset;
    _BitScanForward64(&offset, mask);
    it += offset / 16;
    return it - data;

#else

    return findActionableFromGroundPlain(data, data + count, p);

#endif
}

#pragma warning(pop)

// Routine Description:
// - Helper for entry to the state machine. Will take an array of characters
//     and print as many as it can without encountering a character indicating
//     a escape sequence, then feed characters into the state machine one at a
//     time until we return to the ground state.
// Arguments:
// - string - Characters to operate upon

Review comment (refactor):
`v[c]name[q][_n]_type`
* `v`: vector operation
* `c`: component-wise operation
* `q`: quad double words = 128 bit operation
* `_n`: scalar instead of vector arguments
* name:
  * `ld1`: load bytes (unaligned by default)
  * `dup`: duplicate argument into all components
  * `sub`: subtract
  * `le`: lower or equal
  * `orr`: bitwise or
* type:
  * `s`: signed
  * `u`: unsigned
  * `u8`: 8 bits per component
  * `u16`: 16 bits per component

`vgetq_lane_u64`: extracts the upper/lower 64 bits of the 128 bit vector

Code after:

#elif defined(TIL_ARM_NEON_INTRINSICS)

    auto it = data;
    uint64_t mask;

    for (const auto end = data + (count & ~size_t{ 7 }); it < end;)
    {
        const auto wch = vld1q_u16(it);
        const auto a = vcleq_u16(wch, vdupq_n_u16(0x1f));
        const auto b = vcleq_u16(vsubq_u16(wch, vdupq_n_u16(0x7f)), vdupq_n_u16(0x20));
        const auto c = vorrq_u16(a, b);

        mask = vgetq_lane_u64(c, 0);
        if (mask)
        {
            goto exitWithMask;
        }
        it += 4;

        mask = vgetq_lane_u64(c, 1);
        if (mask)
        {
            goto exitWithMask;
        }
        it += 4;
    }

    return findActionableFromGroundPlain(data, data + count, it);

exitWithMask:
    unsigned long offset;
    _BitScanForward64(&offset, mask);
    it += offset / 16;
    return it - data;

#else

    return findActionableFromGroundPlain(data, data + count, p);

#endif
}

#pragma warning(pop)

// Routine Description:
// - Helper for entry to the state machine. Will take an array of characters
//     and print as many as it can without encountering a character indicating
//     a escape sequence, then feed characters into the state machine one at a
//     time until we return to the ground state.
// Arguments: