Try to append a unique identifier to the buffer. Returns true if appended. */
| 65 | |
| 66 | /* Try to append a unique identifier to the buffer. Returns true if appended. */ |
| 67 | static bool try_append_ident(const char *source, uint32_t s, int len, uint32_t *seen, int seen_size, |
| 68 | uint32_t seen_mask, char *buf, int buf_size, int *pos, int *count) { |
| 69 | uint32_t h = hash_source_span(source, s, len); |
| 70 | uint32_t key = h | FP_HASH_NONZERO; |
| 71 | uint32_t slot = h & seen_mask; |
| 72 | bool dup = false; |
| 73 | for (int p = 0; p < seen_size; p++) { |
| 74 | uint32_t idx = (slot + (uint32_t)p) & seen_mask; |
| 75 | if (seen[idx] == 0) { |
| 76 | seen[idx] = key; |
| 77 | break; |
| 78 | } |
| 79 | if (seen[idx] == key) { |
| 80 | dup = true; |
| 81 | break; |
| 82 | } |
| 83 | } |
| 84 | if (dup || *pos + len + FP_SPACE_SEP >= buf_size) { |
| 85 | return false; |
| 86 | } |
| 87 | if (*pos > 0) { |
| 88 | buf[(*pos)++] = ' '; |
| 89 | } |
| 90 | memcpy(buf + *pos, source + s, (size_t)len); |
| 91 | *pos += len; |
| 92 | (*count)++; |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | /* Walk AST body, collect unique identifier text as space-separated string. |
| 97 | * Contract: the first BT_MAX_IDENTS unique identifiers in pre-order (source |
no test coverage detected