Change the COST() macro to be a "static inline" function. On GCC this makes no difference in performance, but this improves the readability of the function. In a subsequent commit we'll make use of this to extend this function with overflow detection. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- linear-assignment.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/linear-assignment.c b/linear-assignment.c index 1f8329701a0..e9cec16132a 100644 --- a/linear-assignment.c +++ b/linear-assignment.c @@ -6,7 +6,16 @@ #include "cache.h" #include "linear-assignment.h" -#define COST(column, row) cost[(column) + column_count * (row)] +static inline int cost_index(int *cost, int a, int b, int c) +{ + int r; + + r = b + a * c; + + return r; +} + +#define COST(column, row) cost[cost_index(cost, column_count, column, row)] static void columns_reduction(size_t column_count, size_t row_count, int *cost, -- 2.34.1.930.g0f9292b224d