From 35578168becd1e11973bec413f2078a4bf81ba6b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 2 Aug 2021 19:10:38 +0200 Subject: patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Optimizer can use hints about ga_grow() normally succeeding. Solution: Use GA_GROW_FAILS() and GA_GROW_OK() in several places. (Dominique Pellé, issue #8635) --- src/macros.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/macros.h') diff --git a/src/macros.h b/src/macros.h index 4ca24c0f5..ae7ed1a7a 100644 --- a/src/macros.h +++ b/src/macros.h @@ -387,8 +387,10 @@ // Inline the condition for performance. #define CHECK_LIST_MATERIALIZE(l) if ((l)->lv_first == &range_list_item) range_list_materialize(l) -// Inlined version of ga_grow(). Especially useful if "n" is a constant. -#define GA_GROW(gap, n) (((gap)->ga_maxlen - (gap)->ga_len < n) ? ga_grow_inner((gap), (n)) : OK) +// Inlined version of ga_grow() with optimized condition that it fails. +#define GA_GROW_FAILS(gap, n) unlikely((((gap)->ga_maxlen - (gap)->ga_len < n) ? ga_grow_inner((gap), (n)) : OK) == FAIL) +// Inlined version of ga_grow() with optimized condition that it succeeds. +#define GA_GROW_OK(gap, n) likely((((gap)->ga_maxlen - (gap)->ga_len < n) ? ga_grow_inner((gap), (n)) : OK) == OK) #ifndef MIN # define MIN(a, b) ((a) < (b) ? (a) : (b)) -- cgit v1.2.1