Drop "restrict" keyword

The "restrict" keyword can be used to indicate that no other
pointer will be used to access a chunk of memory while the
restricted pointer is alive. If that promise is not upheld,
undefined behavior is triggered.

It may be difficult to ensure this property, and the property may
be brittle - becoming invalid as code evolves. Just like "inline",
let's just leave optimizations up to the compiler to figure out.
This commit is contained in:
Simon Ser 2026-05-25 10:31:55 +02:00 committed by Isaac Freund
parent 3bd8f29b13
commit 7265a79e46
4 changed files with 14 additions and 14 deletions

View file

@ -135,13 +135,13 @@ static bool is_taken(size_t n, const uint32_t arr[static n], uint32_t key) {
*/
struct match_state {
const size_t num_conns;
const uint32_t *restrict conns;
const uint32_t *conns;
const size_t num_crtcs;
size_t score;
size_t replaced;
uint32_t *restrict res;
uint32_t *restrict best;
const uint32_t *restrict orig;
uint32_t *res;
uint32_t *best;
const uint32_t *orig;
bool exit_early;
};
@ -236,9 +236,9 @@ static bool match_connectors_with_crtcs_(struct match_state *st,
}
void match_connectors_with_crtcs(size_t num_conns,
const uint32_t conns[static restrict num_conns],
size_t num_crtcs, const uint32_t prev_crtcs[static restrict num_crtcs],
uint32_t new_crtcs[static restrict num_crtcs]) {
const uint32_t conns[static num_conns],
size_t num_crtcs, const uint32_t prev_crtcs[static num_crtcs],
uint32_t new_crtcs[static num_crtcs]) {
uint32_t solution[num_crtcs];
for (size_t i = 0; i < num_crtcs; ++i) {
solution[i] = UNMATCHED;