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). */
| 5874 | * O(E×N) across the edge loop and spun for >10 minutes on Linux-kernel-sized |
| 5875 | * graphs (~1.4M defs × ~1.4M CALLS edges). */ |
| 5876 | static const char *lookup_pkg(const int64_t *nids, char **npkgs, int nn, int64_t id) { |
| 5877 | int lo = 0; |
| 5878 | int hi = nn - SKIP_ONE; |
| 5879 | while (lo <= hi) { |
| 5880 | int mid = lo + (hi - lo) / PAIR_LEN; |
| 5881 | if (nids[mid] == id) { |
| 5882 | return npkgs[mid]; |
| 5883 | } |
| 5884 | if (nids[mid] < id) { |
| 5885 | lo = mid + SKIP_ONE; |
| 5886 | } else { |
| 5887 | hi = mid - SKIP_ONE; |
| 5888 | } |
| 5889 | } |
| 5890 | return NULL; |
| 5891 | } |
| 5892 | |
| 5893 | /* Accumulate a cross-package boundary into parallel arrays. */ |
| 5894 | static void accum_boundary(const char *src_pkg, const char *tgt_pkg, char **bfroms, char **btos, |