From 93bba0927f0f1d3be8be472a9f4e7312d0be380d Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 31 Dec 2023 12:26:05 -0800 Subject: libs/din: constify din_t for din() din() just samples the din_t which will always just be a read-only operation, so constify this. It might even help the compiler generate faster code for din-heavy inner loops like modules/swab uses. --- src/libs/din/din.c | 2 +- src/libs/din/din.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/din/din.c b/src/libs/din/din.c index aa71a2f..1cb0b97 100644 --- a/src/libs/din/din.c +++ b/src/libs/din/din.c @@ -94,7 +94,7 @@ static inline float smootherstep(float x) { /* coordinate is in a unit cube of -1...+1 */ -float din(din_t *din, v3f_t *coordinate) +float din(const din_t *din, v3f_t *coordinate) { int x0, y0, z0, x1, y1, z1; float i1, i2, ii1, ii2; diff --git a/src/libs/din/din.h b/src/libs/din/din.h index 97823b6..ff25fb4 100644 --- a/src/libs/din/din.h +++ b/src/libs/din/din.h @@ -7,6 +7,6 @@ typedef struct v3f_t v3f_t; din_t * din_new(int width, int height, int depth, unsigned seed); void din_free(din_t *din); void din_randomize(din_t *din); -float din(din_t *din, v3f_t *coordinate); +float din(const din_t *din, v3f_t *coordinate); #endif -- cgit v1.2.1