tweaks: avoid checking a variable three times for each pass in the loop

master
Benno Schulenberg 2020-06-25 09:53:39 +02:00
parent b1b89f01b7
commit e7511abd86
1 changed files with 12 additions and 19 deletions

View File

@ -882,27 +882,20 @@ bool find_a_bracket(bool reverse, const char *bracket_pair)
pointer = line->data + step_right(line->data, openfile->current_x); pointer = line->data + step_right(line->data, openfile->current_x);
/* Now seek for any of the two brackets, either backwards or forwards. */ /* Now seek for any of the two brackets, either backwards or forwards. */
while (TRUE) { if (reverse) {
if (reverse) while (!(found = mbrevstrpbrk(line->data, bracket_pair, pointer))) {
found = mbrevstrpbrk(line->data, bracket_pair, pointer);
else
found = mbstrpbrk(pointer, bracket_pair);
if (found)
break;
if (reverse)
line = line->prev; line = line->prev;
else
line = line->next;
/* If we've reached the start or end of the buffer, get out. */
if (line == NULL) if (line == NULL)
return FALSE; return FALSE;
pointer = line->data + strlen(line->data);
}
} else {
while (!(found = mbstrpbrk(pointer, bracket_pair))) {
line = line->next;
if (line == NULL)
return FALSE;
pointer = line->data; pointer = line->data;
if (reverse) }
pointer += strlen(line->data);
} }
/* Set the current position to the found bracket. */ /* Set the current position to the found bracket. */