summaryrefslogtreecommitdiffstats
path: root/src/macros.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-08-02 19:10:38 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-02 19:10:38 +0200
commit35578168becd1e11973bec413f2078a4bf81ba6b (patch)
tree1eb46d3b958d66b12f83f6e8c583adc33d95a74f /src/macros.h
parent952d9d827e5bfc66a6b1d39956e4e5596b09e2bd (diff)
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeedingv8.2.3275
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)
Diffstat (limited to 'src/macros.h')
-rw-r--r--src/macros.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/macros.h b/src/macros.h
index 4ca24c0f5d..ae7ed1a7ae 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))