Simple hash set for Halstead unique counting (open addressing). */
| 107 | |
| 108 | /* Simple hash set for Halstead unique counting (open addressing). */ |
| 109 | static bool halstead_insert(uint32_t *set, const char *key) { |
| 110 | uint32_t h = 0; |
| 111 | for (const char *p = key; *p; p++) { |
| 112 | h = (h * HALSTEAD_HASH_MUL) + (uint32_t)*p; |
| 113 | } |
| 114 | uint32_t idx = h & HALSTEAD_SET_MASK; |
| 115 | for (int probe = 0; probe < HALSTEAD_SET_SIZE; probe++) { |
| 116 | uint32_t slot = (idx + (uint32_t)probe) & HALSTEAD_SET_MASK; |
| 117 | if (set[slot] == 0) { |
| 118 | set[slot] = h | SKIP_ONE; |
| 119 | return true; /* new */ |
| 120 | } |
| 121 | if (set[slot] == (h | SKIP_ONE)) { |
| 122 | return false; /* existing */ |
| 123 | } |
| 124 | } |
| 125 | return false; |
| 126 | } |
| 127 | |
| 128 | /* Check if an identifier matches any parameter name. */ |
| 129 | static bool is_param_name(const char *ident, const char *source, const char **param_names, |
no outgoing calls
no test coverage detected