2
0
Fork 0
mirror of https://github.com/fish-shell/fish-shell synced 2025-02-13 04:33:33 +00:00

Optimize literal_zero_index comparisons

No longer check literal zero after the first non-zero value.
This commit is contained in:
Mahmoud Al-Qudsi 2018-10-01 21:20:13 -05:00
parent 264d8270a7
commit 3875cc60bd

View file

@ -198,9 +198,12 @@ static size_t parse_slice(const wchar_t *in, wchar_t **end_ptr, std::vector<long
// Explicitly refuse $foo[0] as valid syntax, regardless of whether or not we're going
// to show an error if the index ultimately evaluates to zero. This will help newcomers
// to fish avoid a common off-by-one error. See #4862.
if (literal_zero_index && in[pos] == L'0') {
zero_index = pos;
literal_zero_index = true;
if (literal_zero_index) {
if (in[pos] == L'0') {
zero_index = pos;
} else {
literal_zero_index = false;
}
}
const size_t i1_src_pos = pos;