Skip to content

Commit

Permalink
hash_ids: Add EXPENSIVE_CHECK for ids[] being in ascending order.
Browse files Browse the repository at this point in the history
  • Loading branch information
silentbicycle committed Jan 5, 2024
1 parent 9cba560 commit f39390b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/adt/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#include "adt/common.h"
#include "fsm/fsm.h"

#if EXPENSIVE_CHECKS
#include <assert.h>
#endif

#define HASH_LOG_PROBES 0
/* #define HASH_PROBE_LIMIT 100 */

Expand All @@ -35,6 +39,11 @@ hash_ids(size_t count, const fsm_state_t *ids)
uint64_t h = 0;
for (size_t i = 0; i < count; i++) {
h = hash_id(h ^ ids[i]);
#if EXPENSIVE_CHECKS
if (i > 0) {
assert(ids[i-1] <= ids[i]);
}
#endif
}
return h;
}
Expand Down

0 comments on commit f39390b

Please sign in to comment.