(apply_rules_going_right): minor optimization.

Make easy tests first, call strlen() at the end of test sequence.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2019-02-14 16:31:57 +03:00
parent fd3df33310
commit 6b67d123d9

View File

@ -449,11 +449,12 @@ apply_rules_going_right (WEdit * edit, off_t i)
{
/* when both context and keyword terminate with a newline,
the context overflows to the next line and colorizes it incorrectly */
if (_rule._context != 0 && k->keyword[strlen (k->keyword) - 1] == '\n')
if (e > i + 1 && _rule._context != 0
&& k->keyword[strlen (k->keyword) - 1] == '\n')
{
r = CONTEXT_RULE (g_ptr_array_index (edit->rules, _rule._context));
if (r->right != NULL && r->right[0] != '\0'
&& r->right[strlen (r->right) - 1] == '\n' && e > i + 1)
&& r->right[strlen (r->right) - 1] == '\n')
e--;
}