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:
parent
264d8270a7
commit
3875cc60bd
1 changed files with 6 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue