MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / halstead_insert

Function halstead_insert

src/semantic/ast_profile.c:109–126  ·  view source on GitHub ↗

Simple hash set for Halstead unique counting (open addressing). */

Source from the content-addressed store, hash-verified

107
108/* Simple hash set for Halstead unique counting (open addressing). */
109static 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. */
129static bool is_param_name(const char *ident, const char *source, const char **param_names,

Callers 1

accumulate_halsteadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected