Look up package name for a node ID in the parallel arrays. nids must be * sorted ascending (the node query orders by id) — a linear scan here is * O(E×N) across the edge loop and spun for >10 minutes on Linux-kernel-sized * graphs (~1.4M defs × ~1.4M CALLS edges). */
| 9144 | * O(E×N) across the edge loop and spun for >10 minutes on Linux-kernel-sized |
| 9145 | * graphs (~1.4M defs × ~1.4M CALLS edges). */ |
| 9146 | static const char *lookup_pkg(const int64_t *nids, char **npkgs, int nn, int64_t id) { |
| 9147 | int lo = 0; |
| 9148 | int hi = nn - SKIP_ONE; |
| 9149 | while (lo <= hi) { |
| 9150 | int mid = lo + (hi - lo) / PAIR_LEN; |
| 9151 | if (nids[mid] == id) { |
| 9152 | return npkgs[mid]; |
| 9153 | } |
| 9154 | if (nids[mid] < id) { |
| 9155 | lo = mid + SKIP_ONE; |
| 9156 | } else { |
| 9157 | hi = mid - SKIP_ONE; |
| 9158 | } |
| 9159 | } |
| 9160 | return NULL; |
| 9161 | } |
| 9162 | |
| 9163 | /* Accumulate a cross-package boundary into parallel arrays. */ |
| 9164 | static void accum_boundary(const char *src_pkg, const char *tgt_pkg, char **bfroms, char **btos, |