Per-file metadata for this exact immutable doc pointer, never for a line. */
| 347 | |
| 348 | /* Per-file metadata for this exact immutable doc pointer, never for a line. */ |
| 349 | static doc_line_ent_t *doc_info_of(CBMExtractCtx *ctx, const char *doc) { |
| 350 | doc_line_map_t *m = (doc_line_map_t *)ctx->doc_lines; |
| 351 | if (!m || m->count == 0) { |
| 352 | return NULL; |
| 353 | } |
| 354 | if (!m->sorted) { |
| 355 | qsort(m->items, (size_t)m->count, sizeof(m->items[0]), doc_line_cmp); |
| 356 | m->sorted = true; |
| 357 | } |
| 358 | int lo = 0; |
| 359 | int hi = m->count - SKIP_ONE; |
| 360 | uintptr_t key = (uintptr_t)doc; |
| 361 | while (lo <= hi) { |
| 362 | int mid = lo + ((hi - lo) / PAIR_LEN); |
| 363 | uintptr_t v = (uintptr_t)m->items[mid].doc; |
| 364 | if (v == key) { |
| 365 | return &m->items[mid]; |
| 366 | } |
| 367 | if (v < key) { |
| 368 | lo = mid + SKIP_ONE; |
| 369 | } else { |
| 370 | hi = mid - SKIP_ONE; |
| 371 | } |
| 372 | } |
| 373 | return NULL; |
| 374 | } |
| 375 | |
| 376 | /* ── Persisted scope ─────────────────────────────────────────────── */ |
| 377 |
no outgoing calls
no test coverage detected